Client Credentials vs Authorization Code for a server-side reporting bot

Hey folks,

Quick question on the best OAuth grant type for a specific use case. We’re building a Python script that runs nightly to pull agent performance metrics and wrap-up codes from Genesys Cloud. It’s purely server-side, no human interaction, and it needs to run as a specific service account.

I’ve been using the Authorization Code grant so far because that’s what the docs highlight first, but it feels clunky for a bot. I have to store the refresh token securely and handle the exchange flow every time it expires. It’s working, but I keep seeing references to Client Credentials in the API docs.

Here’s the flow I’m currently using with the genesyscloud Python SDK:

from genesyscloud.auth import OAuthClient

oauth_client = OAuthClient(
 client_id="my_client_id",
 client_secret="my_client_secret",
 auth_host="https://auth.{my_region}.mypurecloud.com"
)

# This requires an authorization URL and user consent, which feels wrong for a script
oauth_client.get_tokens_with_authorization_code(
 code="authorization_code_from_redirect",
 redirect_uri="http://localhost:8080/callback"
)

If I switch to Client Credentials, I can just do:

oauth_client.get_tokens_with_client_credentials()

The issue is, I’m not sure if Client Credentials gives me the right permissions for reading api/v2/analytics/conversations/details/summary. I tried it once and got a 403 Forbidden on the analytics endpoint, even though the service account has the right roles in the UI.

Is Client Credentials strictly for admin tasks? Or did I just miss a step in setting up the scopes? I want to avoid storing refresh tokens if I can help it. The script runs in a Docker container, so env vars are fine for secrets.

Any pointers on the correct setup? I’m tired of debugging token expiry issues in the logs.