Python requests OAuth2 Client Credentials returning 401 Invalid Grant despite valid client_id

Can anyone clarify why my Python script keeps getting a 401 Invalid Grant error when trying to fetch an access token using the Client Credentials grant type against the Genesys Cloud OAuth endpoint? I am building a backend service to generate tokens for a React Native app that uses the Guest API for web messaging, and I need to automate the token refresh process without user interaction. I have double-checked my client_id and client_secret in the Genesys Cloud Developer Portal, and they are definitely correct. I am using the requests library in Python to POST to https://api.mypurecloud.com/oauth/token. Here is the exact code snippet I am running: import requests; url = ‘https://api.mypurecloud.com/oauth/token’; payload = {‘grant_type’: ‘client_credentials’, ‘client_id’: ‘MY_CLIENT_ID’, ‘client_secret’: ‘MY_CLIENT_SECRET’}; headers = {‘Content-Type’: ‘application/x-www-form-urlencoded’}; response = requests.post(url, data=payload, headers=headers); print(response.status_code); print(response.text). The response is consistently 401 with the JSON body: {“error”:“invalid_grant”,“error_description”:“Bad client credentials”}. This is incredibly frustrating because I have used the same credentials successfully in Postman, so I know they work. I have tried changing the content-type header to application/json and passing the payload as json=payload instead of data=payload, but that just gives me a 400 Bad Request error saying the grant_type is missing. I am running this from a server in America/Sao_Paulo, and I have verified that the network allows outbound traffic on port 4443 and standard HTTPS ports. Is there something specific about the Python requests library that interferes with the OAuth2 flow, or is there a hidden requirement for the client_credentials grant that I am missing? I need this working urgently because the mobile app sessions are expiring and I cannot hardcode tokens in the client-side code. Any help would be appreciated.