Connect Next.js app to management api

Hi. I am working on a next.js app. I need to create an endpoint that will return some of the user data from auth0. To do this I decided to use management API, however, as this API requires an access token and Next.js API routes are serverless I am requesting new JWT with an access token in each and every request.
Is this the optimal way to connect to management api? Or is there another recommended approach?

Hi @cnoters,

Thanks for reaching out to the Auth0 Community!

While it is possible to request a Management API access token in every request, it could cause you to go over quota for your Machine-to-Machine Authentication.

Instead, we recommend caching your Management API token rather than requesting a new one each time. This would prevent you from going over quota with Machine-to-Machine Authentication and allow you to continue using your existing M2M access token. Then with this token, you can call the Management API Get a user endpoint to retrieve more information about the user.

Please refer to our Get Management API Access Tokens for Production documentation for more information.

Thanks,
Rueben

1 Like

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