function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
suraj pawar 2suraj pawar 2 

API Integration & SSO

i have created an app in salesforce and provided callback url, i received the code successfully but when i am requesting for token using callback url, client id and client secret key, i am getting an error i.e Invalid grant, authorization code invalid.
Hi Suraj, 

Invalid_grant: the provided authorization code is not valid, has been revoked or has expired (after 5 minutes). Note that both successful and unsuccessful requests revoke the code. Also check that the redirect_uri parameter is included if necessary.

See the similar thread, 

This is a sample of how to get the access_token:


Realize an HTTP POST to https://[login] **you must select between test or login according the environment we want to use (sandbox or production).


** replace default values with values from your org/user

content-tpe: application/x-www-form-urlencoded

Also see the link below,


suraj pawar 2suraj pawar 2
Thanks ashish for your help..!!

i have used grant_type = pasword  and  i am getting the correct reponse i:e access token,  but when i am using grand_type= authorization_code it is giving me an error "Invalid grant, authorization code invalid"  , so can you please help me to rectify this problem

grant_type  authorization_code
Consumer Key  3MVG9e2mBbZnmxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxXe36YpUEhUi3ddV
Consumer Secret  436xxxxxxxxxxxxxxxxxx51
code                    aPrxr1wu_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxDSliVESA%3D%3D
redirect_uri            http://192.168.x.x:8080/sale_f/page.php

These are the parameters i am using !!
Hi  Suraj, 

In the line above it says "grand_type= authorization_code" where grant is spelled as Grand*** check if that is not the issue.