Extract id_token in my react app

I need to extract id_token in my react js app, but i am only able to extract access-token via getAccessTokenSilently method. Does auth0 provide any similar method for extracting id_token in react js app?

Hey @vishal.agarwal!

What’s the use case here if you don’t mind elaborating a bit? If you just need the information contained in ID tokens the following should help:

The use case is, if I send id_token in authorization than everything works fine in the laravel backend but if we send access_token value in the authorization then auth0 middleware is giving unauthorized error.

Technicially, I should use access_token only but I am not able to figure out why id_token is working and access_token is treated as unauthorized by the auth0 middleware in the laravel backend.

BTW, I am using social login and access_token and id_token are received after logging via gmail through auth0 react SDKs.

Thanks for confirming - You should definitely be using the access token against your backend. I believe the issue is related to the access token being opaque as I mentioned here:

Once you include an audience param (AuthorizationParams in auth0-react) in the request to get tokens the middleware should be able to verify the access token successfully. The audience is just the API identifier you use when registering an API in your Auth0 dashboard.

Thank you so much. It worked fine.

1 Like

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