You are designing a REST client that must call an endpoint protected by OAuth 2.0 using the client credentials grant. The authorization server expects the client identifier and client secret to be sent in the request body as `application/x-www-form-urlencoded`, along with `grant_type=client_credentials`. Which `requests` call correctly obtains the token?
The data parameter encodes the dictionary as application/x-www-form-urlencoded, which is exactly what the OAuth 2.0 token endpoint expects for the client credentials grant. Including grant_type, client_id, and client_secret in the body matches the server requirement described in the scenario.
Why this answer
OAuth 2.0 token requests use POST with application/x-www-form-urlencoded bodies. The data parameter in requests performs that encoding automatically. Sending the grant type and client credentials in the body, rather than as Basic auth or JSON, satisfies the server's stated expectations and returns the access token needed for subsequent API calls.