Should I call checkSession whenever need to use an access token for API?

Hi, guys

Should I call checkSession whenever need to use an access token for API? Or should I check expire date for an access token to know whether checkSession should be called or not?

1 Like

Hi @kuma-guy,

If the token is still valid then you can avoid the extra request.

This is handled automatically in the newer auth0-spa-js. The getTokenSilently checks for a cached token before requesting one. If you don’t have a specific reason to use auth0js, you may want to consider using auth0-spa-js as it abstracts away some of these decisions.

Hope this helps,
Dan

1 Like

Thanks for replying!

I use auth0-js because I need to implement login with my own login page & UI.
I understand that auth0-spa-js support redirect login with Rock or popup login and not fully migrated auth0-js features yet.
Is that right?

If my understating is right, should I implement to checkSession like as in auth0-spa-js/getTokenSiltenly?

Yes that is correct!

1 Like

Thank for quick response!

I have more confidence to implement my Auth0 integrations.

thanks again for the helps.

1 Like

Good luck with your project!

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