msgraph-sdk-go
msgraph-sdk-go copied to clipboard
The token used for this request is expected to be at least 45 minutes away from expiry.
trafficstars
Given the following function where we cache the creation of the client to avoid re-creating the client for each request we do to the graph we are getting the following error and there is nothing we can do about it.
func (g *graph) getClient(tenantId uuid.UUID) (....) {
cred, err := azidentity.NewClientSecretCredential(
tenantId.String(),
g.cfg.ClientID,
g.cfg.ClientSecret,
&azidentity.ClientSecretCredentialOptions{},
)
if err != nil {
return nil, err
}
client, err = msgraphsdk.NewGraphServiceClientWithCredentials(cred, defaultScope)
if err != nil {
return nil, errors.Wrap(err, "failed to create graph client")
}
return client, nil
}
The error we are experiencing
The token used for this request is expected to be at least 45 minutes away from expiry.
The token that was passed expires in 8 minutes and 23 seconds. Please use a fresher token.