SaxoBank / openapi-samples-js

Sample code demonstrating OpenAPI interactions in JavaScript

Home Page:https://www.developer.saxo/openapi/learn

Repository from Github https://github.comSaxoBank/openapi-samples-jsRepository from Github https://github.comSaxoBank/openapi-samples-js

Get Token_access failing

mattdoub opened this issue · comments

Hello,

Thx vm for thoses samples. very useful.
In OAuth2 Code Flow example
After redirect, get_code works fine but get_token fails with the following error:
localhost/:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

Any idea why?
PS: I've used the live gateway in this test with correct Appkeys and links

commented

Hi Matt,

The samples were tested in SIM only at this point. I think the URL you are trying to access does not exist (which yields a 404 with HTML body). When this body is being parsed, JSON fails because it gets a HTML open bracket <.

I will put an item on our to-do list to update the samples for both environments. For now you can check the URL that is used for the get_token function and make sure it is pointing at the LIVE one instead of SIM. URLs can be found here: https://www.developer.saxo/openapi/learn/environments