Home > OS >  Auth0 Angular - How to read access token in application immediately after login
Auth0 Angular - How to read access token in application immediately after login

Time:09-07

I am using auth0-spa-js in my angular application. However, after successful user authentication I am not sure how can I read access token. I have read couple of article but still its not clear.

I have tried following way in Auth Guard but I get undefined.

 this.auth0Service.getAccessTokenSilently().subscribe(data=>{
            console.log(data);
        });

Can someone help here pls?

Thanks.

CodePudding user response:

You can get the access token like this.

auth0.getIdTokenClaims().subscribe(claims => console.log(claims.__raw))

CodePudding user response:

--- ANSWER ---

Hi,

I done some more analysis and come to know that we don't need to call handleredirectcallback() while using Auth0-spa-js sdk as it take care internally. As I was calling this function explicitly it was causing an issue to get access token.

Thanks, Jaydeep S

  • Related