[SalesForce] Authentication Failure when submitting Authorization Code in OAuth Web-Server Flow

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

Best Answer

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.