{“code”:“invalid_grant”,“message”:“Invalid authorization code.”} keeps popping up when i hit POST /api/v2/oauth/token. trying to set up a python script that runs hourly to pull queue stats and drop them into a local csv. don’t need any human login flow, just a backend service account on a linux vm.
read the oauth docs but the grant types are confusing. authorization_code needs a redirect uri and browser flow which feels wrong for a cron job. client_credentials seems right for machine-to-machine but the scope requirements are messy. do i need analytics:reporting alone or does it require user:read too? the token only lasts 30 minutes so managing refreshes in a simple script is already annoying.
here’s the curl i’m testing:
curl -X POST “https://api.mypurecloud.com/api/v2/oauth/token”
-H “Authorization: Basic bXljbGllbnQ6bXlzZWNyZXQ=”
-d “grant_type=client_credentials&scope=analytics:reporting”
gets a token fine, but calling /api/v2/analytics/reporting/queues/summary throws a 403. am i missing a scope mapping or is the client credentials grant just blocked for reporting endpoints? the platform ui shows different scopes available depending on the grant type selected. stuck on this.