Get an access token for a different audience

Using auth0-spa-js I can get an access token for a new audience as described here:

Is there an equivalent function in the auth0-js SDK?

I presume there isn’t, as the official documentation advises creating a single logical API and naming the scopes accordingly. But this will lead to an API will hundreds of scopes that are maintained by different teams, and the potential for collisions is significant.

I am creating a microservice-based application. I want my users to log in and receive an access token with an audience that identifies the first microservice they will use; but then have the ability to call back to Auth0 and get an access token for a new audience as they navigate to a new microservice. Do I have to upgrade to auth0-spa-js in order to be able achieve this? Or can I use some variation of silent authentication to accomplish the task?

You can pass a new audience (as well as scope) to Auth0.js’s checkSession function. This is more or less the equivalent of getTokenSilently in that it performs silent authentication.

Please see here for further details:

1 Like

Excellent! Thanks very much for the reply, Richard.

1 Like

We’re here for you @graham.e!

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