5

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

  • Do you have my domain set on your dev org? – AtulRajguru9 Jul 8 '16 at 4:41
  • is your callback url in your connected App same as that you are sending in request? – Pranay Jaiswal Jul 8 '16 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"} – Anil Shivaraj Jul 8 '16 at 13:28
7

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
    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 :) – Anil Shivaraj Jul 8 '16 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.