Jump to content

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


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


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.'




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?




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.



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

  • Create New...