Jump to content

Issues with Authentication / Callback URL for a AWS Lamda function using the Sage API


Recommended Posts

Hi all, 

Our team is currently developing an AWS Lamda function that is supposed to automatically insert the names of new customers from one of our databases into our Sage Business Cloud Accounting account. To do so, we have followed this guide to work our way through the authentication process: https://developer.sage.com/api/accounting/guides/authentication/ 

However, we run into difficulties when being asked to provide a Callback URL for our app. More specifically, we are unsure what URL to provide for the Lamda function.

When we leave it blank or insert localhost for the Callback URL, the following error is produced upon submitting a request to renew an access token:  {"$severity":"error","$dataCode":"DataParsingError","$message":"The data you sent could not be processed.","$source":"Proxy"}

Therefore, we are wondering what URL we should provide and whether it is even possible to renew the access token when using a Lamda function. If the latter is the case, are there any workarounds through which we can renew the access token and accomplish what we intend with the Lamda function?

We would appreciate it if you have any thoughts on this.

Best regards, 

Christopher Wekel

Link to comment
Share on other sites

I've just gone through the process of getting the oAuth callback to work and have posted simplistic demo code in an earlier thread:

Oauth2 Authorisation and IIS - Support - Sage Developer Community

You need to have logic in the callback to retrieve the code sent from sage and then request the tokens.

I found this easiest to do on a development machine using localhost.  If you don't use localhost you need to use https.  

One thing to note is the token is refreshed without using the callback url, so it may be something that you only need to do initially as long as your refresh token does not expire (30 days?).

  • Like 1
Link to comment
Share on other sites

  • Administrators

Hi Christopher,

Whilst I haven't tried, I do not believe its possible to use a lambda function and specify a callback url? Stuart's point is a good one, that if you can handle the initial authentication to retrieve a valid refresh token elsewhere, then use that in the url-encoded body of a refresh request as per our authentication guide, that will likely work.

POST https://oauth.accounting.sage.com/token
Content-Type: application/x-www-form-urlencoded




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