Js SDK: token mgmt

Hello everyone.

We are using the Js SDK to reproduce some client functionalities and we realize that it doesn't seem to be possible to obtain the oauth token requested internally by the sdk. According to the code it is persisted on a "localStorage" structure, but it seems private. On the other hand we could use the api implicitly to perform the auth but then it would also not be possible to persist the token in this "localStorage", right? It is important to us to get the token because we need to keep it within the user session of our front-end.

Also (not sure if it maters) we are temporarily using implicit grant method but as soon as our client sets their ADFS we will be using SAML. I think the issue remains in both approaches, right?

Thank u.
Regards,
Daniel Grosso
Lisbon, Portugal

You can retrieve the access token via platformClient.ApiClient.instance.authentications['PureCloud Auth'].accessToken.

All OAuth flows result in an access token. However, the JavaScript SDK does not contain a helper for SAML auth, so you'll need to build that process out yourself. That will give you the auth token that you'll need to provide to the SDK, which makes retrieving the access token from the SDK moot.

Hello Tim, first of all, we really appreciate the quick assistance (specially yours) on this forum, it's been very helpful.

We understand the absence of an helper for SAML auth but this doesn't mean we can't use the SDK for everything else, right? Would it be enough to set variable above with the previously obtained token?

Best regards,
Daniel

1 Like

Take a look at the Authentication section in the JS SDK docs. You can provide your own auth token that you obtained outside of the SDK (e.g. from a SAML flow):

var client = platformClient.ApiClient.instance;
client.setAccessToken(yourAccessToken);
// Do authenticated things; no login function needed

:wink: got it

Thank u.

Regards,
Daniel

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.