Client Credentials vs Auth Code for server-side reporting bot

Setting up a Python script to pull historical interaction data from Genesys Cloud every night. It’s a headless process running on an AWS Lambda. No human logging in.

I’ve been reading the OAuth docs and I’m torn between two approaches.

  1. Client Credentials Grant: Seems cleaner for a service-to-service thing. I just swap the client ID and secret for a token.
  2. Authorization Code Grant: Usually for user apps, but maybe I need it if the reporting needs to act ‘as’ a specific admin user to bypass certain scope limits?

Here’s the basic token request I’m testing with Client Credentials:

import requests

url = "https://api.mypurecloud.com/oauth/token"
payload = {
 "grant_type": "client_credentials",
 "client_id": "my_app_id",
 "client_secret": "my_secret"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}

response = requests.post(url, headers=headers, data=payload)
print(response.json())

This works fine. I get a token back. But when I try to hit /api/v2/analytics/interactions/queries, I get a 403 Forbidden. The error says Insufficient privileges.

If I switch to using a personal access token (which is basically Authorization Code flow with a long-lived refresh), it works instantly.

Is Client Credentials inherently more restricted for analytics endpoints? Or am I missing a scope in the app setup? I’ve added analytics:read to the app, but maybe that’s not enough for a machine account?

Just want to make sure I’m not building this wrong before I deploy it to prod.