+ Start a Discussion
Akash MangroliyaAkash 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,
 
{
     "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. 
JyothsnaJyothsna (Salesforce Developers) 
Hi,

You need to authorize the application for once with the "authorize URL". You don't have to make the redirect_uri work.
Authorize Url:
 
https://login.salesforce.com/services/oauth2/authorize?client_id=[client_id]&redirect_uri=[redirect_url]&response_type=code



Regards,
Jyothsna
Akash MangroliyaAkash Mangroliya
Hi 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.
Akash MangroliyaAkash Mangroliya
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. 
Akash MangroliyaAkash Mangroliya
Hi,
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"
}

 
GT1945GT1945
I also have a user with the same issue, am seeing the error in the logs and as a results leads are not being ingested:

"error" : "invalid_grant", 
  "error_description" : "user hasn't approved this consumer"
 
Admin User 9203Admin User 9203
was anyone able to solve this?
 
Fabian Manzano 6Fabian Manzano 6
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
 
Harleen Mann 8Harleen Mann 8
"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.