Can client_id and client_secret be sent in the request URI?

Client credentials not included in the request URIRFC 6749 §2.3.1MUST NOTRoles: authorization_server

Requirement as recorded in the ProtocolSoup registry

The parameters can only be transmitted in the request-body and MUST NOT be included in the request URI.

Read §2.3.1 in RFC 6749

Self-test verdict

PassCommit 00bac3fEvaluated

This is ProtocolSoup's result against its own implementation at the commit shown. It is not a certification of ProtocolSoup or of any other product.

Captured from production

Captured Commit 00bac3f

Captured from the deployed ProtocolSoup at the commit shown. Every request and response is shown exactly as sent and received.

Passing exchange

Accepted, as requiredConformance client

The conformance client requests a client_credentials token as machine-client with client_id and client_secret in the request body.

Requests from ProtocolSoup’s conformance client, which sends malformed messages on purpose. The hosted wallet never sends these.

  1. 1.POST https://protocolsoup.com/oauth2/token200 OK

    TLS: TLS 1.3 · TLS_AES_128_GCM_SHA256 · h2

    Request

    POST /oauth2/token HTTP/2.0
    Content-Length: 101
    Content-Type: application/x-www-form-urlencoded
    Host: protocolsoup.com
    User-Agent: ProtocolSoup-Conformance-Client/1
    
    client_id=machine-client&client_secret=M7BkBJ_iK8Gp4ReF1SvGCqluxMn2ySru&grant_type=client_credentials

    Response

    HTTP/2.0 200 OK
    Cache-Control: no-store
    Cf-Cache-Status: DYNAMIC
    Cf-Ray: a65ba3e51e113cdb-MSP
    Content-Type: application/json
    Date: Sun, 06 Dec 2026 13:29:34 GMT
    Fly-Request-Id: 01M95RQATMFXY3WK539P4WVXG9-ord
    Nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
    Pragma: no-cache
    Referrer-Policy: strict-origin-when-cross-origin
    Report-To: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=kM4p%2FyluS%2F5qqCx%2F%2FDHIdJtTvr4ecHHKu46gB0jmxovk8SsKcETqGUsNMMdgzUBL6X0AVtHbYPbA15i54bh505k9LH2EDhOAqefovtZG6n7CXeWkxnYSxHope27j9%2FBKpqY%3D"}]}
    Server: cloudflare
    Server-Timing: cfCacheStatus;desc="DYNAMIC"
    Server-Timing: cfEdge;dur=4,cfOrigin;dur=222
    Vary: Origin
    Vary: accept-encoding
    Via: 1.1 fly.io, 1.1 fly.io
    X-Content-Type-Options: nosniff
    X-Frame-Options: DENY
    X-Xss-Protection: 1; mode=block
    
    {"access_token":"eyJhbGciOiJSUzI1NiIsImtpZCI6InJzYS05YTJlNThlYzVjNjk3NGJmIiwidHlwIjoiYXQrand0In0.eyJhdWQiOiJodHRwczovL3Byb3RvY29sc291cC5jb20vb2F1dGgyL3Jlc291cmNlIiwiY2xpZW50X2lkIjoibWFjaGluZS1jbGllbnQiLCJjbGllbnRfbmFtZSI6Ik1hY2hpbmUtdG8tTWFjaGluZSBDbGllbnQiLCJleHAiOjE3OTY1NjczNzQsImlhdCI6MTc5NjU2Mzc3NCwiaXNzIjoiaHR0cHM6Ly9wcm90b2NvbHNvdXAuY29tL29hdXRoMiIsImp0aSI6Imp0aS0zN2JlMDljZDFiMjM5OWZiIiwibmJmIjoxNzk2NTYzNzc0LCJzY29wZSI6ImFwaTpyZWFkIGFwaTp3cml0ZSIsInN1YiI6Im1hY2hpbmUtY2xpZW50In0.bdi83dhL0W5yK4cXi1_RTEMzCQ6YM8wD2HWXzLh7qpHGi9XiuKdbAazTApTRy_7JH2181uAf3ukRig-Wx8BlWyDypfiDqYzvQVNTyN0-Ogru7SvwHDcmET9tmLaVLATf2U2_rRFDtzzcymEw_utxtxtnQ8DKP3pJSBaOfTXmhXOfZTcBc5-Yhq6wETz1EqmcLDriUDIDmiVD2ihLeVEyHE2s1mAzQl3yCr_3GqfTd9Ho9I57LvFYyGH2rrqNPU9vEZqXRys2i6cFS7jXgOXGQYASKs_dGpB8_0uO2HvRARwJjRJMHPrkx5XcU_A6kNPNEPBO6-8uEVwP28csdgsKvA","token_type":"Bearer","expires_in":3600,"scope":"api:read api:write"}
    

Failing exchange

Rejected, as requiredConformance client

The conformance client sends two client_credentials token requests as machine-client: one with client_id and client_secret in the query component of the request URI, and one with client_id in the body and client_secret in the query component. The secret is the client's real one.

Requests from ProtocolSoup’s conformance client, which sends malformed messages on purpose. The hosted wallet never sends these.

  1. 1.POST https://protocolsoup.com/oauth2/token?client_id=machine-client&client_secret=M7BkBJ_iK8Gp4ReF1SvGCqluxMn2ySru400 Bad Request

    TLS: TLS 1.3 · TLS_AES_128_GCM_SHA256 · h2

    Request

    POST /oauth2/token?client_id=machine-client&client_secret=M7BkBJ_iK8Gp4ReF1SvGCqluxMn2ySru HTTP/2.0
    Content-Length: 29
    Content-Type: application/x-www-form-urlencoded
    Host: protocolsoup.com
    User-Agent: ProtocolSoup-Conformance-Client/1
    
    grant_type=client_credentials

    Response

    HTTP/2.0 400 Bad Request
    Cache-Control: no-store
    Cf-Cache-Status: DYNAMIC
    Cf-Ray: a65ba3f7dad83cdb-MSP
    Content-Type: application/json
    Date: Sun, 06 Dec 2026 13:29:37 GMT
    Fly-Request-Id: 01M95RQDQN3Z6AQ8X1CVN6WDSA-ord
    Nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
    Pragma: no-cache
    Referrer-Policy: strict-origin-when-cross-origin
    Report-To: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=aG7SCRlzGFQuzDds2NDlDQpwte8TwcjuZizmbgzGjeHDLP7bxnjGwNwKc%2FNDA52qE9Wf6EaHrkiSePr%2FUfuypP5%2FP%2FJ%2Fd0NKNLKf5yeiK1Hr281u24C28LkNI9iLvfMe%2FZ0%3D"}]}
    Server: cloudflare
    Server-Timing: cfCacheStatus;desc="DYNAMIC"
    Server-Timing: cfEdge;dur=3,cfOrigin;dur=200
    Vary: Origin
    Vary: accept-encoding
    Via: 1.1 fly.io, 1.1 fly.io
    X-Content-Type-Options: nosniff
    X-Frame-Options: DENY
    X-Xss-Protection: 1; mode=block
    
    {"error":"invalid_client","error_description":"Client authentication failed","error_uri":"https://datatracker.ietf.org/doc/html/rfc6749#section-5.2"}
    
  2. 2.POST https://protocolsoup.com/oauth2/token?client_secret=M7BkBJ_iK8Gp4ReF1SvGCqluxMn2ySru400 Bad Request

    TLS: TLS 1.3 · TLS_AES_128_GCM_SHA256 · h2

    Request

    POST /oauth2/token?client_secret=M7BkBJ_iK8Gp4ReF1SvGCqluxMn2ySru HTTP/2.0
    Content-Length: 54
    Content-Type: application/x-www-form-urlencoded
    Host: protocolsoup.com
    User-Agent: ProtocolSoup-Conformance-Client/1
    
    client_id=machine-client&grant_type=client_credentials

    Response

    HTTP/2.0 400 Bad Request
    Cache-Control: no-store
    Cf-Cache-Status: DYNAMIC
    Cf-Ray: a65ba3fe1ea03cdb-MSP
    Content-Type: application/json
    Date: Sun, 06 Dec 2026 13:29:38 GMT
    Fly-Request-Id: 01M95RQEPXD1YWBH8GS8A34ZME-ord
    Nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
    Pragma: no-cache
    Referrer-Policy: strict-origin-when-cross-origin
    Report-To: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=p4LW3kzbF%2FAHu5CboUYe0CwwLP%2Ff74vHv1OSit%2BkMab3e7VMCH3Q3wZ9c%2F6gdlFjwFh3Os1BRECqHQ32gvT%2F6dXVjvEWdCuNyqRPsRTRg7LzHP0e2SvWf9AVERINFDUHJdI%3D"}]}
    Server: cloudflare
    Server-Timing: cfCacheStatus;desc="DYNAMIC"
    Server-Timing: cfEdge;dur=3,cfOrigin;dur=195
    Vary: Origin
    Vary: accept-encoding
    Via: 1.1 fly.io, 1.1 fly.io
    X-Content-Type-Options: nosniff
    X-Frame-Options: DENY
    X-Xss-Protection: 1; mode=block
    
    {"error":"invalid_client","error_description":"Client authentication failed","error_uri":"https://datatracker.ietf.org/doc/html/rfc6749#section-5.2"}
    

Tests

Implementation

Explainer

What this requires

No: client_id and client_secret must not be sent in the request URI. When a client sends its credentials as parameters, client_id and client_secret go in the request body and nowhere else. RFC 6749 Section 2.3.1 already treats this method as second best, calling it "NOT RECOMMENDED" and something that "SHOULD be limited to clients unable to directly utilize the HTTP Basic authentication scheme". The sentence this row quotes narrows it further: of the places a parameter could go, only the body is allowed.

The MUST NOT binds the client that builds the request. The authorization server's side of it is not to make the wrong request work. A server that reads client_secret from the query string authenticates clients that are breaking the rule, and nobody finds out.

Why it exists

A request URI is recorded in places a body is not: web server and proxy access logs, load balancer logs, monitoring tools, and browser history when a human pastes the URL. A client secret in the query string ends up stored in all of them, in clear text, for as long as those logs are kept.

What non-compliance looks like

Most web frameworks merge query and body parameters by default. Go's r.FormValue, for one, reads both. A token endpoint written with such a helper accepts POST /token?client_id=...&client_secret=... and issues tokens, and the secret is in the access log from then on.

At /oauth2/token that request is not authenticated. The response is 400 with error invalid_client and error_description Client authentication failed, the same as for a request with no credentials. A request with everything in the URI, grant_type included, and an empty body is answered invalid_request with grant_type is required in the request entity-body.

How ProtocolSoup tests it

The token endpoint reads every parameter from the parsed request body. TestTokenEndpointDoesNotReadParametersFromTheRequestURI registers a confidential client and sends four requests: credentials in the body (200), both credentials in the query string (400 invalid_client), client_id in the body with client_secret in the query string (400 invalid_client), and the whole request in the query string (400 invalid_request).

The captured passing exchange, credentials-in-the-body, is machine-client requesting a client_credentials token with both parameters in the body. The failing one, credentials-in-the-request-uri, sends the client's real secret in the query string twice and records both refusals.

Related requirements

All RFC 6749 requirements · OAuth 2.0 protocol page