Skip to content

Multiple audiences with spa 2.x - Requires usage of scope/claims in access tokens to work correctly instead of id token #940

@AndreasA

Description

@AndreasA

Checklist

Description

Hi,

I already created an issue in the spa.js library auth0/auth0-spa-js#1457

The change to store the id token per client id and not per audience was by design.

The proposed solutions, however, are not that easily doable in combination with auth0-react because there is no easy way to access the access token claims / scopes of the Auth0Provider.

In order to help it should be possible to access the access token data which would be fine in our use case as the scopes etc. are valid for the SPA access token and used to show corresponding data.

However, the id token is replaced on another audience call, which creates issues as they should not have all scopes the SPA has by design, only the ones relevant for that API.

See issue: auth0/auth0-spa-js#1457

Reproduction

  1. Use latest auth0-spa-js
  2. use latest auth0-react
  3. Use SPA with audienceA
  4. Use API with audienceB
  5. Add scopes/claims to access token (and id token) of audienceA, but not audienceB
  6. call getAccessToken... with audienceB manually before calling that API.

The user object of audienceA is lost as it is replaced with audienceB.

Furthermore, as there is no way to access claims/scopes etc. of the access token of audienceA, there is no easy way around this.

See issue: auth0/auth0-spa-js#1457

Additional context

See issue: auth0/auth0-spa-js#1457

auth0-react version

2.9.0

React version

19

Which browsers have you tested in?

Chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions