Skip to content

user is not updated after getAccessTokenSilently({ignoreCache: true}) #109

@type

Description

@type

Describe the problem

When you refresh the access token and ignore the cache, there are potentially new claims on the user object. However, the user object is stale and there is no way to update it. auth0/auth0-spa-js#274 explains the issue and has a solution: you can call getUser() after you refresh the token. But we have no way to call getUser().

Right now, to get around this, you must hard-refresh the page.

Exposing the getUser function from the auth0-spa-js client would solve this.

What was the expected behavior?

The user object should have all the claims of the new token.

Reproduction

Create a rule in auth0 that sets a property e.g.

function (user, context, callback) {
  user.app_metadata = user.app_metadata || {};

if (user.app_metadata.mything) {
   context.idToken['https://myapp.com/mything'] = true;
   context.accessToken['https://myapp.com/mything'] = true;
}
  callback(null, user, context);
}

Periodically call getAccessTokenSilently({ignoreCache: true}) without refreshing/reloading the page. Observe the user from useAuth0(). It will not have the claim. Refreshing the page will populate the user with the claim.

Environment

Version: 1.0.0
Browsers: Chrome

Metadata

Metadata

Assignees

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