How to refresh user info with useAuth0() hook? - React

Hi,

We are trying to enforce email verification manually in our React/Auth0 application (there’s a long complicated reason why it can’t be done via login rules). We are using useAuth0().user to check the email_verified status. Whenever a new page is loaded or the current page is refreshed/reloaded, the user info updates. However, I am trying to get the user to update without the page having to be fully loaded (ie, they are on a page that repeatedly updates and checks the email verification status, and is able to register that they have verified the email without them re-loading the page).

How are we able to refresh the user info from Auth0 without reloading the page?

I noticed there is a getCredentials hook for the react native sdk that will do that, but there doesn’t appear to be this call for the react sdk.

I have tried calling getAccessTokenSilently in multiple places and then checking the user data, but it does not change or update.

Also I’m sorry the tags are wrong, the UI is not giving me many options (ie I can’t select react or auth0, etc)

The solution is to call loginWithRedirect() it hits the /authorize endpoint and refreshes the user.

1 Like

Hey there!

As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!

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