7

I am trying to test the Webserver OAuth as described here

I can get the authorization code successfully by opening https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=(xxxxxx) &redirect_uri=https://www.getpostman.com/oauth2/callback. This results in the Code after the authorization is complete

Now comes the problem, for some reason when i try to use the 'code' for the POST request to the https://login.salesforce.com/services/oauth2/token, i am getting {"error":"invalid_grant","error_description":"authentication failure"} even though all parameters are correct. I have also relaxed all IP restrictions.

I was reading this, but again my endpoint is correct since this is a DE org and all parameters look ok, am i missing anything. Attaching screenshot for reference,enter image description here

4
  • Do you have my domain set on your dev org? Commented Jul 8, 2016 at 4:41
  • is your callback url in your connected App same as that you are sending in request? Commented Jul 8, 2016 at 7:14
  • Yes @PranayJaiswal - callback url is same as the sending request, otherwise it will give the error {"error":"redirect_uri_mismatch","error_description":"redirect_uri must match configuration"} Commented Jul 8, 2016 at 13:28
  • Can i ask where do you get the code value from. Im don't have any ideas
    – JPG
    Commented Aug 4, 2020 at 16:32

1 Answer 1

11

Are you copying your authorization code from browser redirect? Its getting URL encoded and hence its saying invalid authorization code.

Check if your auth code is ending with "%3D%3D" replace that with "==" .

This solved my problem plenty of times.

2
  • 2
    this solved my problem, thanks a lot pranay. Yes it was indeed the == issue at the end, i had missed that one and that caused the issue. Thanks a lot guys for all ur inputs :) Commented Jul 8, 2016 at 13:29
  • Hello, i don't know where to get the code value from. Is it the initial access token?
    – JPG
    Commented Aug 4, 2020 at 16:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .