getIdTokenClaims resolves successfully but returns `undefined` for ID Claims


I’m using the auth0-react(v1.0.0) sdk in my application. I first call the getAccessTokenSilently method which resolves successfully and returns the desired access token. In a child component, I call the method getIdTokenClaims because I want the user information of the user. The promises resolves successfully but the claims that I receive are undefined.

Unable to understand what could be the issue here since this was working just fine few days back.

Hi @naman,

Can you post the code? I want to try it out.

Sure @dan.woda ,

In the parent component, I check for access token in the componentDidMount lifecycle method like this.

            .then(res => {
                console.log("Access Token", res);
            .catch(e => {
                console.debug('Error fetching access token', e.message)

In the child component, I get the identity of the user using getIdTokenClaims like this

getIdTokenClaims().then(claims => {
        console.log("ID Token ==> ", claims);
      }).catch(err => {
        console.debug("Something went wrong", err);

Attached is a screenshot of what I can see in the console

I was able to get the ID token claims back in the code you posted. It must have something to do with the initial request, or maybe it is a react specific issue. I am using the auth0 react quickstart. Did you use a quickstart?

When I check the network requests, I can see that the correct id_token is being returned in the request(from the /token endpoint). However, when I try to get it via the sdk, I get undefined as the result.

My use case is this:
I have a user who is already logged into the tenant and the app. I check for an existing session using getAccessTokenSilently method. Since that resolves successfully, I know that there is an existing session. Then I call the getIdTokenClaims method in order to know which user it is. I expect the sdk to resolve only when it has found claims and not return undefined. Is there anything I can tweak from the options?

I checked with embedded lock and there when I call the lock.getUserInfo (after validating with lock.checkSession), I am able to get the correct claims. Is there anything I can do in terms of passing extra parameters which could help me debug further.

Appreciate all the help!

Update: I tried the auth0-spa-js library and I it works fine for me again so looks like this is definitely a problem with the react sdk

1 Like

Since you have narrowed this down as an issue with the react SDK, it would be best to report it directly to the managers of the repo. Could you please submit an issue in the repo for the SDK?

1 Like

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