I’m building out an SPA in React. I see a “quickstart” recipe that suggests:
const user = await auth0.getUser();
I’m looking for reference documentation on this getUser call. I found a likely candidate. That document has what appears to be exactly what I seek –getUser(userid, callback). Sadly, that item is bound to http://localhost:8080/Management.html#getUser (at least on my system).
I like auth0. I invite guidance about how to actually find and read documents like this.
In this case, I want to understand aspects like:
Where do I get the userid?
What happens if I provide an invalid userid?
Is this how I learn whether a given user is signed in or not?
I would REALLY like an actual self-contained reference manual, rather than a web of unreliable href elements.
The library you’ve linked to auth0.js is designed for embedded login, which is no longer recommended in favor of "Universal "or centralized login. Is there is a specific reason you need to implement embedded login? Universal Login is the better option for most use cases as outlined here:
If you can implement a centralized login flow, considering you are working with React I recommend you take a look at this quickstart and the sample app that goes with it. The auth0-react API reference can be found here.
@tyf (sorry about nesting, I never seem to click the correct “Reply” button)
Heh – ok, that’s excellent and valuable to know. I really appreciate your immediate and
helpful attention.
BTW, the quickstart link you cited is how I got where I am (I think!). I built out the sample app (separately) and then migrated the relevant behavior to my app. I use the MUI (formerly Material UI) React component library, so there are at least a few major differences because of the MUI context requirements.
Now I’m curious – I’m pretty sure that I lifted the approach I’m using (const { isAuthenticated, loginWithRedirect, logout } = useAuth0();) directly from the SPA sample app that you linked to. Now I have to go try that again and see!
I’ll try the “centralized login” approach and see if I can make it work for me.
Thanks again for this incredibly informative response. I’ll save all these links. I strongly encourage you to pin a topic here or on the main site that captures this valuable information.
I’ll mark your answer as a “Solution”. Thanks again!
I did some digging, and so far as I can tell I’m already using centralized login. In the tenant settings, I’ve already selected the “New Universal Experience”.
I’ve been poring through the documentation you provided and trying to pick out the simplest way forward for me.
I’m still doing battle with various callback URLs specified in the client settings for my client, and that’s better for its own topic.
I’ve been using the useAuth0 hook from auth0 in my React front-end code:
import { useAuth0 } from "@auth0/auth0-react";
So far as I can tell from the documentation , this is the recommended approach for centralized login.