How to generate long-lived API token for CI/CD pipeline in Genesys Cloud?

Can’t get this config to load properly…

I am trying to set up a GitHub Actions workflow to deploy updates to our Genesys Cloud instance using the CX-as-Code CLI. Currently, my script fails because the OAuth access token expires after an hour, and I cannot hardcode credentials in the repository.

I need to generate a long-lived API token that can be stored securely as a secret in GitHub. However, I am confused about the grant types and scope requirements. The documentation is sparse on this specific use case for CI/CD pipelines.

“For server-to-server authentication, use the client credentials grant type. This allows you to obtain an access token without user interaction.”

I tried using the /api/v2/oauth/token endpoint with the client_credentials grant type, but I am getting a 403 Forbidden error. Here is my request payload:

{
 "grant_type": "client_credentials",
 "client_id": "my-app-id",
 "client_secret": "my-secret"
}

The response is:

{
 "errors": [
 {
 "code": 403,
 "message": "Forbidden",
 "description": "You do not have permission to access this resource."
 }
 ]
}

I assumed that creating a new app in the Developer Portal would give me the necessary permissions, but I am unsure if I need to assign specific scopes like admin or integration:write. Also, does the token generated via client credentials have a longer expiry than user-based tokens? I want to avoid refreshing it every hour in my pipeline.

Can anyone provide a working example of how to generate and use a long-lived API token for CI/CD? I am using Python to make the initial request, but I can switch to curl if needed. I am based in Mexico City, so timezone might affect token expiry, but I doubt it.

Any help would be appreciated. I am new to OAuth and struggling with the nuances of grant types.