Angular getAccessTokenSilently with detailedResponse not working

My app flow is as follows:
When the app loads, I call AuthService.getAccessTokenSilently( {detailedResponse:true}) and I store the access_token and expires_in in session. The access_token for interceptor and expires_in for a timer to refresh the token before expiry.

But I am facing an issue with the getAccessTokenSilently function: When the user has to login (when there is no active session) and comes back to the app, the function returns an object containing both access_token and id_token:

But when the user is already logged in (no redirection), the function just returns the access_token instead of the object even though detailedResponse is passed as true.

The angular version is 12 and the auth0 version is 1.9.0. I need the expires_in to setup refresh and without it, I have to redirect the user even though he is already logged in. What am I missing?

1 Like

I agree with You!

Why are you saving those token yourself? It’s done with library

I am also facing the same issue. I couldn’t find any relevant documentation around this and have been trying to find alternative via a Pop-up login … but that is becoming annoying to use… Basically don’t want to push the user to log-in everytime…

I don’t think the library has this well made or is missing documentation around this. Either way, I still can’t find a way around it

This issue has been reported but not reproduced Wrong getTokenSilently return type depending on cache state · Issue #857 · auth0/auth0-spa-js · GitHub

You should try to reproduce it with the provided branch and then it will be fixed