Jump to content

Authorization Problem


Recommended Posts

Hi,

I have some code (c#) working which retrieves an authorization code using clientid and secret values. I am then trying to exchange this code (which was stored in a string variable) for access and refresh tokens. The request body is being built thus:

string.Format("code={0}&redirect_uri={1}&client_id={2}&client_secret={3}&grant_type=authorization_code"

The value for code is taken from a variable into which the code value as retrieved from the initial authorization call. The redirecturi, clientid and clientsecret values are taken from the same variables used in the initial authorization code call. And yet this second call fails with the attached message. I can't understand why given that the values it's complaining about are simply coming from the same variables both times?

Cheers

Reg Jackson

Screenshot 2021-02-19 164901.jpg

Link to post
Share on other sites

Hi Reginald, thank you for your question.

To clarify, are you attempting to exchange a refresh_token for an access_token? If this is correct you need to make a POST request to the token endpoint https://oauth.accounting.sage.com/token with the following attributes:


Content-Type: application/x-www-form-urlencoded

client_id=4b6xxxxxxx710
&client_secret=iNuxxxxxxxxxxtm9
&grant_type=refresh_token
&refresh_token=eyJxxxxxxxxxxYLk


The Content_Type attribute should be set in the request header and the client_id, client_secret, grant_type and refresh_token set in the request body. I extracted the above from our Auth guide which offers a complete overview of the process.

Regards

Mark

Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...