• Akash Mangroliya
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies
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. 
I want to get access token using java rest but getting error like
{
"error": "unsupported_grant_type"
"error_description": "grant type not supported"
}
This is the request,
POST https://login.salesforce.com/services/oauth2/token
Content-Type: application/x-www-form-urlencoded
client_id:3MVG9ZL0ppGP5UrB5oz4M4HieQ2*******************KNvxN60DVCptuS5c
client_secret:493********************774
redirect_uri:https://localhost/myapp
code:aPrxqJ8A8kLOza8S3awq7IR9_.EZGOpsrHjfBAZTZOWKk0c5YpaLvJLsz_EVQfHLL5taX4hnVA%3D%3D
grant_type:authorization_code

I am passing all the parameter currectly but still getting error.
Somebody help me please :)
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. 
I want to get access token using java rest but getting error like
{
"error": "unsupported_grant_type"
"error_description": "grant type not supported"
}
This is the request,
POST https://login.salesforce.com/services/oauth2/token
Content-Type: application/x-www-form-urlencoded
client_id:3MVG9ZL0ppGP5UrB5oz4M4HieQ2*******************KNvxN60DVCptuS5c
client_secret:493********************774
redirect_uri:https://localhost/myapp
code:aPrxqJ8A8kLOza8S3awq7IR9_.EZGOpsrHjfBAZTZOWKk0c5YpaLvJLsz_EVQfHLL5taX4hnVA%3D%3D
grant_type:authorization_code

I am passing all the parameter currectly but still getting error.
Somebody help me please :)