We recently switched our org to SAML SSO for agent login. Now our Python script that pulls WFM adherence data is failing. It used to work fine with just username and password, but now it’s throwing a 401 error when trying to get the access token.
I’m using the standard client credentials grant. I have the client_id and client_secret from the platform app. The endpoint is /oauth/token.
Here’s the code snippet I’m running:
import requests
url = "https://api.mypurecloud.com/oauth/token"
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
payload = {
"grant_type": "client_credentials",
"scope": "wfm:adherence:view"
}
response = requests.post(url, auth=(client_id, client_secret), headers=headers, data=payload)
print(response.status_code)
print(response.json())
The response is:
{
"error": "invalid_grant",
"error_description": "The grant type is not supported."
}
I read somewhere that SAML might disable certain OAuth flows. Is there a different grant type I should use? Or do I need to create a new user specifically for this? I don’t want to expose credentials in the code if I can help it.