Which characters may the error parameter of a token error response contain?

Token error code limited to the allowed charactersRFC 6749 §5.2MUST NOTRoles: authorization_server

Requirement as recorded in the ProtocolSoup registry

Values for the "error" parameter MUST NOT include characters outside the set %x20-21 / %x23-5B / %x5D-7E.

Read §5.2 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

Not captured: The requirement constrains an error response, so every exchange that shows it is a refusal. The failing exchange is that response.

Failing exchange

Rejected, as requiredConformance client

The conformance client sends four token requests, each with a value that carries a double quote, a backslash or a non-ASCII character where the token endpoint might echo it: an unknown grant_type, an unknown client_id, a made-up authorization code and, as machine-client, an unregistered scope. In each error response, error and error_description stay within %x20-21 / %x23-5B / %x5D-7E and error_uri within %x21 / %x23-5B / %x5D-7E.

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/token400 Bad Request

    TLS: TLS 1.3 · TLS_AES_128_GCM_SHA256 · h2

    Request

    POST /oauth2/token HTTP/2.0
    Content-Length: 47
    Content-Type: application/x-www-form-urlencoded
    Host: protocolsoup.com
    User-Agent: ProtocolSoup-Conformance-Client/1
    
    client_id=public-app&grant_type=%22%C3%A9%22%5C

    Response

    HTTP/2.0 400 Bad Request
    Cache-Control: no-store
    Cf-Cache-Status: DYNAMIC
    Cf-Ray: a65babf3981d3cdb-MSP
    Content-Type: application/json
    Date: Sun, 06 Dec 2026 13:35:04 GMT
    Fly-Request-Id: 01M95S1D35H6DM6P9ZH2JWG4ME-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=RFweqEults8tsfWnNE1Fr3OeDrbB9K1bsmsqD3HxbEhwASsFzPcQ%2BYmAIAYTt%2Fts4J8sxhuECIHHCOMQ9TplvX1nWnHOnA%2FzICAq4BEFU6mjj4JHo7IcXH6B%2BWTH2xNigRk%3D"}]}
    Server: cloudflare
    Server-Timing: cfCacheStatus;desc="DYNAMIC"
    Server-Timing: cfEdge;dur=3,cfOrigin;dur=220
    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":"unsupported_grant_type","error_description":"Grant type not supported","error_uri":"https://datatracker.ietf.org/doc/html/rfc6749#section-5.2"}
    
  2. 2.POST https://protocolsoup.com/oauth2/token400 Bad Request

    TLS: TLS 1.3 · TLS_AES_128_GCM_SHA256 · h2

    Request

    POST /oauth2/token HTTP/2.0
    Content-Length: 62
    Content-Type: application/x-www-form-urlencoded
    Host: protocolsoup.com
    User-Agent: ProtocolSoup-Conformance-Client/1
    
    client_id=%22%C3%A9%22%5C&code=x&grant_type=authorization_code

    Response

    HTTP/2.0 400 Bad Request
    Cache-Control: no-store
    Cf-Cache-Status: DYNAMIC
    Cf-Ray: a65babf9deb73cdb-MSP
    Content-Type: application/json
    Date: Sun, 06 Dec 2026 13:35:05 GMT
    Fly-Request-Id: 01M95S1E1P5W94RCH6D29J4QZ3-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=krI9mtC8FMuNzkPQbAxTelNCJSvFxCP8%2BiHloVEAg3aHs0hvCgI9pyA4FKdupLA%2BtDrdDzNgO459IAQuVbvfBN%2B6xFW5KQgkIARaL0C1te01Bp22bQcW4R%2BhgaODE4EoloI%3D"}]}
    Server: cloudflare
    Server-Timing: cfCacheStatus;desc="DYNAMIC"
    Server-Timing: cfEdge;dur=4,cfOrigin;dur=196
    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":"Unknown client","error_uri":"https://datatracker.ietf.org/doc/html/rfc6749#section-5.2"}
    
  3. 3.POST https://protocolsoup.com/oauth2/token400 Bad Request

    TLS: TLS 1.3 · TLS_AES_128_GCM_SHA256 · h2

    Request

    POST /oauth2/token HTTP/2.0
    Content-Length: 126
    Content-Type: application/x-www-form-urlencoded
    Host: protocolsoup.com
    User-Agent: ProtocolSoup-Conformance-Client/1
    
    client_id=public-app&code=%22%C3%A9%22%5C&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fprotocolsoup.com%2Fcallback

    Response

    HTTP/2.0 400 Bad Request
    Cache-Control: no-store
    Cf-Cache-Status: DYNAMIC
    Cf-Ray: a65bac001d6d3cdb-MSP
    Content-Type: application/json
    Date: Sun, 06 Dec 2026 13:35:06 GMT
    Fly-Request-Id: 01M95S1F0WSVDZ9GBHYR9MCGFW-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=OYniOTrA8afTp%2FcRCxVVw0c6woODcBqs%2FqxGRH7dhWSncOl7GqolbEdSGXxI6xxkSmtjzEPLzLPp1ujl5T4pfV6vUqRXxDXZUdBK%2Fhv2CupawnAP8q127bmI5CkMec5xg7k%3D"}]}
    Server: cloudflare
    Server-Timing: cfCacheStatus;desc="DYNAMIC"
    Server-Timing: cfEdge;dur=2,cfOrigin;dur=196
    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_grant","error_description":"invalid authorization code","error_uri":"https://datatracker.ietf.org/doc/html/rfc6749#section-5.2"}
    
  4. 4.POST https://protocolsoup.com/oauth2/token400 Bad Request

    TLS: TLS 1.3 · TLS_AES_128_GCM_SHA256 · h2

    Request

    POST /oauth2/token HTTP/2.0
    Authorization: Basic bWFjaGluZS1jbGllbnQ6TTdCa0JKX2lLOEdwNFJlRjFTdkdDcWx1eE1uMnlTcnU=
    Content-Length: 51
    Content-Type: application/x-www-form-urlencoded
    Host: protocolsoup.com
    User-Agent: ProtocolSoup-Conformance-Client/1
    
    grant_type=client_credentials&scope=%22%C3%A9%22%5C

    Response

    HTTP/2.0 400 Bad Request
    Cache-Control: no-store
    Cf-Cache-Status: DYNAMIC
    Cf-Ray: a65bac065b093cdb-MSP
    Content-Type: application/json
    Date: Sun, 06 Dec 2026 13:35:07 GMT
    Fly-Request-Id: 01M95S1G05N322FXE60CAGTQ3R-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=lKDEQuOpKcrtyHA1x%2FlWQotp9BzRtX70BLDPv7ekNcHEzl4vW2qHd%2FcPTl8Q3t5tOXe%2FHrofWCG8m11CqJwlpNjo5f%2BT6E5qD6gCHQ1XyVbRmKyIIpS5HQMFDEP7ra4bhyY%3D"}]}
    Server: cloudflare
    Server-Timing: cfCacheStatus;desc="DYNAMIC"
    Server-Timing: cfEdge;dur=3,cfOrigin;dur=197
    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_scope","error_description":"None of the requested scopes are permitted for this client","error_uri":"https://datatracker.ietf.org/doc/html/rfc6749#section-5.2"}
    

Tests

Implementation

Explainer

What this requires

The error parameter of a token error response may contain printable ASCII characters other than the double quote and the backslash. The set %x20-21 / %x23-5B / %x5D-7E runs from the space to the tilde and leaves out %x22, the double quote, and %x5C, the backslash. Nothing outside ASCII and no control characters.

For the error member this is easy to meet and easy to stop thinking about. Section 5.2 lists the codes of the token endpoint: invalid_request, invalid_client, invalid_grant, unauthorized_client, unsupported_grant_type and invalid_scope. Extensions register more. All of them are lower-case words joined by underscores. The requirement matters when a server builds a code from something else.

Why it exists

Error codes are read by programs and carried in more than one syntax. The token endpoint puts the code in a JSON string. The authorization endpoint puts it in a URI. RFC 6750 puts it in a WWW-Authenticate header as a quoted string. The double quote and the backslash are the two characters that end or escape a quoted string, so excluding them means a code can be copied between those places without re-encoding.

What non-compliance looks like

A server that derives the code from an exception class, a localized message or a client-supplied value. The last one is an injection point: if the code is later written into a header inside quotes, a double quote in it closes the string early.

How ProtocolSoup tests it

Every error code this server returns is a constant in the source. None is built from request data. TestTokenErrorParametersUseTheAllowedCharacters sends about twenty refused requests to /oauth2/token, many of them carrying a double quote, a backslash and a non-ASCII character in the value at fault (the grant type, the client identifier, the code, the scope, the resource, a DPoP header), and asserts that the error of every response stays inside the set. It also asserts the run produced each of the six Section 5.2 codes at least once.

Only a failing exchange is captured, because the requirement constrains an error response. error-parameters-of-refused-requests sends four such requests and checks the codes returned: unsupported_grant_type, invalid_client, invalid_grant and invalid_scope.

Related requirements

All RFC 6749 requirements · OAuth 2.0 protocol page

Which characters may the error parameter of a token error response contain? · RFC 6749 §5.2 | ProtocolSoup