-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recommended way to re-inject renewed token for Management API in a long-running script? #164
Comments
@alexstrat I have the same issue. Do you mind sharing your implementation for |
@dcworldwide here is what i'm using today. You'll find an implementation in |
Thanks @alexstrat |
@alexstrat thank you for your snippet, I just embraced your solution and created a simple Koa middleware with it. I can clean it up a bit and post it on GitHub if anyone is interested. |
If anyone else is still interested, this middleware is now running in a production ready app |
This is part of the SDK now: https://github.com/auth0/node-auth0#management-api-client |
I got a script running indefinitely (a web server actually) that needs to access the Management API. I manually generate a token, like described here, use it, but after 24h it's expired. Normal.
I understood I got to automate the process of periodically generate a new token and inject it in my running script (right?), but can't find any recommended way to do it, nor come up with an elegant solution.
The solution I'm using now looks like this:
It's clumsy and un-elegant, esp. because I got to asynchronously get the client each time I need it.
Has anyone found a better method?
It would be much better if the
ManagementClient
could hide that logic and asynchronousity:Alternatively, the
ManagementClient
could add the possibility to dynamically inject the token and let the developer responsible for generating and caching the tokenThe text was updated successfully, but these errors were encountered: