
I setup all the related things like create the App and upload the certificate and also create the currect JWT token as per doc Hereand post the following request for access token,{
"error" : "invalid_grant",
"error_description" : "user hasn't approved this consumer"
}
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.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);
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 windowsI am still facing the same issue, you guys are not helping in the support team, check google and you will see all developers facing the same althought they follow your corrupted Help forms , You guys leave me no chance but to change to other CRM for integration. Hi Jyothsna,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. I am still getting this issue and not able to fix it.I have followed the steps as is https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_jwt_flow.htm&type=5&language=en_US.Can someone help me. I have already done the authorization. Hi Folks - Thanks for this thread. Based on @tiagobernardo's response here, I got to double-checking my values and found that when connecting to my sandbox SF instance, I was incorrectly using production username (an email address), whereas sandbox account has a slightly different username (email addres + some ".123dev" kind of string appended. Once corrected, my integration against sandbox now works :) I hope this helps someone. 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:
{"error":"invalid_grant","error_description":"user hasn't approved this consumer"}
I was using https://jwt.io to validate content of the Header and Payload of the JWT token:
Header:
{
"alg": "RS256",
"typ": "JWT"
}
Payload (omitting the value for the "iss" Claim):
{
"sub": "<an-email-as-a-username>",
"jti": "9a65de7b-8972-445a-8b36-8fd06d7923f7",
"nbf": 0,
"exp": 1618830145,
"iat": 0,
"iss": "3MVG9(...omitted...)D3y",
"aud": "https://test.salesforce.com"
}
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
Even I have tried all the steps mentioned here 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 "user hasn't approved this consumer" This is a common error caused when the user doesn't have a prior refresh_token associated with him/her.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. Same question, did anyone solve this?I authorize my app after opening the link, but getting this error when trying to do an api call