I’m currently using the Auth0 ManagementClient
from the auth0
npm package in my Next.js app in a singleton pattern like this:
import { ManagementClient } from 'auth0';
let managementClient: ManagementClient | null = null;
const getManagementClient = () => {
if (!managementClient) {
managementClient = new ManagementClient({
domain: process.env.AUTH0_MANAGEMENT_API_DOMAIN,
clientId: process.env.AUTH0_CLIENT_ID,
clientSecret: process.env.AUTH0_CLIENT_SECRET,
});
}
return managementClient;
};
My question is:
Does the ManagementClient
automatically handle access token renewal after the token expires (e.g., after the default 24 hours)? Or do I need to handle the token renewal manually if I’m using a singleton like this?
If manual renewal is needed, what’s the recommended best practice for this?
Thanks in advance!