In Auth0-SPA-JS, how do I get the user (`id_token`)?

Question: In auth0-spa-js, how do I get the user (id_token)?

Solution:

You can get the id_token using the getUser call.

For example, after authenticating, you could call the Auth0 Client like this:

const user = await auth0Client.getUser();

Update: The raw id token is now available via this method:


$('#getIdTokenClaims').click(async () => {
  const claims = await auth0.getIdTokenClaims();
  // if you need the raw id_token, you can access it
  // using the __raw property
  const id_token = claims.__raw;
});

Supporting Documentation:

2 Likes