Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"error":"invalid_grant","error_description":"invalid authorization code" in salesforce

I have setup my 'Salesfore' connected App for 'OAuth' using which I am able to authenticate user. For subsequent request I am trying to get access token hence posting values to Salesforce as below.

$.post("https://login.salesforce.com/services/oauth2/token",
                {
                    "grant_type": "authorization_code",
                    "code": "00DXXXX5",
                    "client_id": "3MVXXXXK",
                    "client_secret": "15XXXX4",
                    "redirect_uri": "https://mysit11e.com/SalesforceCallback.aspx"
                });

but unfortunately I am having an error

"error":"invalid_grant","error_description":"invalid authorization code"

I have made sure there is not % symbol is not present in code hence replaced %21 with !.

What else shall I try to get this working.

like image 837
Imad Avatar asked May 04 '26 19:05

Imad


1 Answers

you appear to be posting it as json try posting it as a request string

grant_type=authorization_code&code=00DXXXX5&client_id=3MVXXXXK&client_secret=15XXXX4&redirect_uri=https://mysit11e.com/SalesforceCallback.aspx
like image 139
DaImTo Avatar answered May 06 '26 17:05

DaImTo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!