Hello All,
My api authentication token lifetime is big, I want to make the management api client singleton so that I don’t need to generate token every time and initiate management api client for each request.
Now the question is whether management api client is capable or not to make it singleton because, behind the scene, its call http request and I don’t know whether the socket connection keep live for long?
You shouldn’t need to get a new token every time you want to make a request. I am not sure on making it a singleton, but the management client may allow you to store the token, then request a new one when it expires, rather than instantiating a new client for every request. What library/language are you working with?
Hello Dan, I am using .net nuget packages:
package id=“Auth0.AuthenticationApi” version=“7.0.2” targetFramework=“net462”
package id=“Auth0.Core” version=“7.0.2” targetFramework=“net462”
package id=“Auth0.ManagementApi” version=“7.0.2” targetFramework=“net462”
When the management api life time elapsed, if I want to access any api, it shows
ErrorApiException {“Expired token received for JSON Web Token validation”}.
Its normal that it’ll show this error, it shows the error when the token lifetime expires. My concern is, if I made the token lifetime more longer, hence as token is not expiring, I don’t need to create management api client again, is management api client same instance can I use for a longer period? Fyi, management api client of the Auth0 library uses http client