building a background worker in .NET 8 to pull historical conversation metrics. running on an Azure App Service.
i’m using the genesyscloud_platformsdk nuget package. initialized the client like this:
var config = new PureCloudPlatformClientV2.Configuration
{
ApiKey = apiKey,
ApiSecret = apiSecret,
BaseUrl = "https://api.mypurecloud.com"
};
var client = PureCloudPlatformClientV2.ClientFactory.CreateApiClient(config);
first run works fine. gets the access token. pulls data.
second run (15 minutes later) throws:
PureCloudPlatformClientV2.ClientException: (401) Unauthorized
Response: {"status":401,"code":"invalid_token","message":"The access token is invalid or expired"}
the docs for the .NET SDK say:
“The SDK automatically handles token refresh when using Client Credentials flow.”
but it’s not happening. the ApiClient object is being reused via a static singleton.
is this a known issue with the latest nuget version (2.14.0)? or am i supposed to manually call GetToken every time?
also, should i be using Authorization Code flow instead? the app has no UI. just a service account pulling data. client creds seems right but the auto-refresh is broken.
here is the stack trace snippet:
at PureCloudPlatformClientV2.ApiClient.MakeHttpRequest(HttpMethod method, String path, ...
any ideas?