Reginald Jackson Posted February 19, 2021 Share Posted February 19, 2021 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 Link to comment Share on other sites More sharing options...
Steel, Mark Posted February 19, 2021 Share Posted February 19, 2021 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 comment Share on other sites More sharing options...
Reginald Jackson Posted February 21, 2021 Author Share Posted February 21, 2021 Hi, I solved this by changing the content type to Json and specifying the parameters that way... Link to comment Share on other sites More sharing options...
Administrators Ben Smith Posted February 22, 2021 Administrators Share Posted February 22, 2021 Hi Reginald, Thanks for letting us know! Ben Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now