How to get access token in angular with '@auth0/auth0-angular' library

Please include the following information in your post:

  • Which SDK this is regarding: auth0/auth0-angular
  • SDK Version: 1.10.1
  • Platform Version: Angular 12
  • Code Snippets/Error Messages/Supporting Details/Screenshots:

Hi Team,

I am using above mentioned sdk to configure Auth0 in my angular application.

I have imported AuthModule in my module.ts as below.

image

In my auth-callback component, I am want to get access token, but when I call ‘handleRedirectCallback’ then I get below error:

image

As per the stackoverflow thread, we dont need to call ‘handleRedirectCallback()’

but as per the library comment, we should call this function:

It’s really confusing, can someone help here?

Thanks,
Jaydeep S

Hey there @Jaydeeps03!

I believe the documentation may be out of date here in saying that you need to call handleRedirectCallback() directly:

hey I done some more research and come to know that we have to call handleRedirectCallback() function in call back URL. I was getting ‘Invalid State’ error because I made mistake while importing auth module, somehow I was initiating that twice in my application and this was causing generating two different states.

Hope this will help someone in future.

1 Like

Awesome, good to know you were able to get this sorted and thanks for following up with the community :slight_smile:

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