Jump to content

Sage Accounting generate access token and refresh token error - The submitted \"code\" has not been found.


 Share

Recommended Posts

Hi all,

I had a problem when generating refresh and access token using authorization code.

As following I got an authorization code successfully generated. https://localhost/callback?code=CA%2F675ef9d5-690b-4e8f-8bfa-ca7a6bc8dcb4&country=CA&state=any

image.thumb.png.ca01906313da8c6414277254823e2f4e.png

When I tested it in Postman (with CA%2F675ef9d5-690b-4e8f-8bfa-ca7a6bc8dcb4 as code ), I got the error 'The auth code you transmitted has an unexpected format.'

'

image.thumb.png.e9427df97725683dfde048dc3649a66d.png

 

when as suggested in (https://developer-community.sage.com/topic/206-issue-with-oauth20-access-token/) , %2F was replaced by /, the error 'The submitted \"code\" has not been found.' happened.

Could you please help me to understand which part of the returned code (CA%2F675ef9d5-690b-4e8f-8bfa-ca7a6bc8dcb4) should be used with which adjustment?

image.thumb.png.8acc9248d0a4c5e4cc1703d5443a2050.png

 

Thanks

Link to comment
Share on other sites

Hi @weiszahn,

The code needs to be url encoded and you would need to use CA/675ef9d5-690b-4e8f-8bfa-ca7a6bc8dcb4 in this example. The code expires after 30 seconds so that it the probable cause of the failure.

POSTMAN's inbuilt oauth flow deals with this and you shouldn't need to manually add the code. If you take a look at the initial auth request together with the environment we provide in https://developer.sage.com/accounting/quick-start/preparing-to-create-test-data/ you'll be able to successfully authenticate once you've added your client credentials to the provided environment. 

Don't forget to add the default POSTMAN callback url against your app in the app registry https://developerselfservice.sageone.com/session/new.

https://www.postman.com/oauth2/callback - POSTMAN app
https://oauth.pstmn.io/v1/browser-callback - POSTMAN browser

Collection - https://developer.sage.com/accounting/files/test-data/SBC_Accounting_Data_Creation_postman_collection.json
Environment - https://developer.sage.com/accounting/files/test-data/SBC_Accounting_Data_Creation_postman_environment.json 

Let me know how you progress.

Thanks

Mark

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...