Messaging media upload

Following this article:

For the step [

Upload the media

](https://developer.genesys.cloud/commdigital/digital/webmessaging/messaging-media-upload#upload-the-media)

In the example they make a callout to POST https://apps.mypurecloud.com/uploads/v4/services/messaging/{id}

It is not done through any SDK, but instead a plan ajax callout. We need explicit access to the bearer token to do that. How do we manage this in a context where the rest of the API callouts in the web app are being done through Javascript SDK (that doesn't need explicit access to the bearer token). Is there any way to safely retrieve the token from the Client App SDK so we can do this ajax callout?

Hello,

I assume that you are using the Platform API Javascript SDK to log in and to obtain a token for your app/code.

The token is available as a result of the loginImplicitGrant method. I mean:

const apiClient = platformClient.ApiClient.instance;
apiClient.loginImplicitGrant(clientId, redirectUri, { state: state })
  .then((data) => {
    console.log(data);
    let myToken = data.accessToken;
    // Do authenticated things
  })
  .catch((err) => {
    // Handle failure response
    console.log(err);
  });

The token should also remains available through apiClient.authData (i.e. apiClient.authData.accessToken)

Regards,

Yes, javascript SDK. I could finally get access to it through platformClient.ApiClient.authData.accessToken
Thanks!

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