Getting a 401 Unauthorized when my Azure DevOps pipeline tries to use the OAuth token. The token expires way too fast.
I am using the .NET SDK to get the token.
var client = new PureCloudPlatform.Client.V2.ApiClient();
var auth = new OAuthApi(client);
var token = await auth.PostOAuthApiAccessTokenAsync(clientId, clientSecret, "client_credentials");
The docs say:
“Access tokens are short-lived and should be refreshed using the refresh_token.”
But for a CI/CD pipeline, I need something that lasts longer than an hour. The build takes 45 minutes and then the deployment starts. By the time the deployment hits the API, the token is dead.
I tried setting the scope to admin, but that did not change the expiry. Is there a way to request a longer TTL? Or do I need to store the refresh token and call the endpoint again? The client_credentials flow does not give a refresh token in the response.
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "bearer",
"expires_in": 3600
}
No refresh_token field. How do I handle this without breaking the pipeline?