I’m working on my first real project using Auth0 as an identity management solution and have run into a bit of a question:
I see that when you use the NodeJS library (auth0
) that you’re supposed to create an instance of auth0.ManagementClient
and then use that to complete tasks via the Management API (such as manual creation of users, etc.)
That’s fine, but I also read that if you provide adequate credentials, that you can automatically generate a token to make requests with subject to expiration based on expires_in
settings, etc.
Do I need to create a new instance of ManagementClient
for each request or is it adequate to create one instance during server startup and export that to places that need it?
It seems to me (correct if wrong) that if I create one instance, then export…things will be fine up until I hit the expiration and then all of my ManagementClient
-based reqeusts will fail due to an expired token?
I just wanted to ask here and make sure I was right in that thinking so I would know what the best practice was for creating instance(s) of ManagentClient
before I got to writing user registration code for my new project (I am doing this using a custom form that I built using React for my frontend).
Alternatively: Should I even be doing it this way? I was under the impression that I would need to incorporate the Management API (via Express) to handle custom registrations, and that there wasn’t a way to do this in React itself…otherwise I wouldn’t even need to do this in Express?
I read a little bit about the Authentication REST API and maybe the best way to handle this is just using that API with axios
on the client?
Thanks in advance for any advice/assistance.
I’m pretty new to Auth0 in general (it’s awesome so far!), and I can’t figure out which is the more optimal/preferred way to deal with these registration requests.