I recently implemented user authentication in my react web app using Auth0. And I need to retrieve some information from user object. I did this so far:
cost { user, isAuthenticated } = useAuth0();
<p>{user.name}</p>
But I also want to get user's id, so I can reference them later in my backend. So I did this:
const { user, isAuthenticated } = useAuth0();
<p>{user.user_id}</p>
And when I go to the website I get undefined instead of the user's id.
Is it happening because I use dev-keys for my social connections, or maybe it has to be done differently?
Not sure if you are still searching for this problem, however I had a similar problem and found this as a solution:
const { user, isAuthenticated } = useAuth0();
<p>{user.sub}</p>
source: https://community.auth0.com/t/how-to-get-user-id-of-a-user-after-login-in-react-hook-useauth0/53309
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With