You need to sign in to do that
Don't have an account?
Akash Mangroliya
{ "error" : "invalid_grant", "error_description" : "user hasn't approved this consumer"}
I have to use Oauth JWT flow to got the access token but while i execute my code then it show me following error,
I setup all the related things like create the App and upload the certificate and also create the currect JWT token as per doc Here
and post the following request for access token,
And I also accept the application and related permission by following request,
https://login.salesforce.com/services/oauth2/authorize?client_id=3MVG9ZL0ppGP5UrDITkMBDGuTYGHeynoEt40ZRWCcaYsycFHYDcm2LnqukCNurLNx33LH1c.0rrfG8VrQaqri&redirect_uri=https://localhost/myapp&response_type=code
I think I done all the things to get the access token but I M GETTING ERROR.
Could you please somebody help me for solving this problem.
Thank You.
{ "error" : "invalid_grant", "error_description" : "user hasn't approved this consumer" }
I setup all the related things like create the App and upload the certificate and also create the currect JWT token as per doc Here
and post the following request for access token,
HttpPost httpPost = new HttpPost("https://login.salesforce.com/services/oauth2/token"); httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded"); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("grant_type", "urn:ietf:params:oauth:grant-type:jwt-bearer")); params.add(new BasicNameValuePair("assertion", clientAssertion)); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse response = httpClient.execute(httpPost);
And I also accept the application and related permission by following request,
https://login.salesforce.com/services/oauth2/authorize?client_id=3MVG9ZL0ppGP5UrDITkMBDGuTYGHeynoEt40ZRWCcaYsycFHYDcm2LnqukCNurLNx33LH1c.0rrfG8VrQaqri&redirect_uri=https://localhost/myapp&response_type=code
I think I done all the things to get the access token but I M GETTING ERROR.
Could you please somebody help me for solving this problem.
Thank You.
You need to authorize the application for once with the "authorize URL". You don't have to make the redirect_uri work.
Authorize Url:
Regards,
Jyothsna
I authorize the application using following request,
https://login.salesforce.com/services/oauth2/authorize?client_id=3MVG9ZL0ppGP5UrDITkMBDGuTYGHeynoEt40ZRWCcaYsycFHYDcm2LnqukCNurLNx33LH1c.0rrfG8VrQaqri&redirect_uri=https://localhost/myapp&response_type=code
But Still it give the same error.
Thanking you for reply.
I refer the same link and I follow same to same as per link but then also it give me error.
Thank You for help :)
I try to give end point Url in remote site setting but then also it give same error
"error" : "invalid_grant",
"error_description" : "user hasn't approved this consumer"
I authorize my app after opening the link, but getting this error when trying to do an api call
The solution is to perform an Autorization grant (Web Server flow or User-Agent Flow) at least once.
I wrote in detail about it; look **specifically at step #3** here - https://mannharleen.github.io/2020-03-03-salesforce-jwt/
That should solve the error.
Just change the order of parameters you are passing for ClaimSet :
Body jsonClaim = new Body(iss,prn,aud,exp);
.
.
Body(string iss,string prn,string aud,string exp){ this.iss=iss; this.aud=aud; this.prn=prn; this.exp=exp; }
Hope It works for you as well. Good Luck!
https://mannharleen.github.io/2020-03-03-salesforce-jwt/
but still getting the error
error_description: "user hasn't approved this consumer"
Any ideas about be greatly appreciated
Hi all!
I was bagging my head against the wall with this problem; it worked (using a JWT token to request an OAuth Access token) on my developer cloud SalesForce environment (at login.salesforce.com, Organization Edition: Developer Edition) but when I moved to a company Sanbox environment (at test.salesforce.com) it did not work...
I was following all necessary configurations, everything seemed to be fine, I could generate the JWT token (using the correct value "https://test.salesforce.com" for the Audience ("aud") Claim) but when using it to request the OAuth Access token it was gave me the error:
I was using https://jwt.io to validate content of the Header and Payload of the JWT token:
Header:
Payload (omitting the value for the "iss" Claim):
The problem turned out to be that I was still sending the request for the OAuth Access token, supplying the JWT token, to the URL login.salesforce.com, instead of using the correct URL test.salesforce.com.
So, double-check that you are sending the request to the correct URL, as for me everything now works!
Note: Using API Version 51.0.
--Tiago Bernardo
I had the same error. To resolve it, I had to give the permissions to my user (System Administrator) of the connected app.
Steps to grant permissions:
* Left sidebar: Apps -> Connected Apps -> Manage Connected Apps
* Click on "Edit"
* Select at "Permitted Users" -> "Admin approved users are pre-authorized"
* Save it
* In the same section "Manage Connected Apps" click on your connected app to see the policies
* Section "Profiles" -> click "Manage Profiles" -> select "System Administrator"
* Click "Submit" -> Click "OK" in modal windows