Does an authorization error response return the state parameter the client sent?

state returned exactly in the authorization error responseRFC 6749 §4.1.2.1REQUIREDRoles: authorization_server

Requirement as recorded in the ProtocolSoup registry

state REQUIRED if a "state" parameter was present in the client authorization request. The exact value received from the client.

Read §4.1.2.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

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 public-app's authorization request with scope=api:read, which is not registered for the client, and a state that uses a space and the characters & = + % #. The authorization server returns invalid_scope to the redirect_uri with the state exactly as it was sent.

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

  1. 1.GET https://protocolsoup.com/oauth2/authorize?client_id=public-app&redirect_uri=https%3A%2F%2Fprotocolsoup.com%2Fcallback&response_type=code&scope=api%3Aread&state=a+b%26c%3Dd%2Be%2520%23f302 Found

    TLS: TLS 1.3 · TLS_AES_128_GCM_SHA256 · h2

    Request

    GET /oauth2/authorize?client_id=public-app&redirect_uri=https%3A%2F%2Fprotocolsoup.com%2Fcallback&response_type=code&scope=api%3Aread&state=a+b%26c%3Dd%2Be%2520%23f HTTP/2.0
    Accept: text/html
    Host: protocolsoup.com
    User-Agent: ProtocolSoup-Conformance-Client/1
    
    

    Response

    HTTP/2.0 302 Found
    Cache-Control: no-store
    Cf-Cache-Status: DYNAMIC
    Cf-Ray: a65ba9761fa53cdb-MSP
    Content-Type: text/html; charset=utf-8
    Date: Sun, 06 Dec 2026 13:33:22 GMT
    Fly-Request-Id: 01M95RY9EX3HG9B9JHWT3AS3K5-ord
    Location: https://protocolsoup.com/callback?error=invalid_scope&error_description=None+of+the+requested+scopes+are+permitted+for+this+client&iss=https%3A%2F%2Fprotocolsoup.com%2Foauth2&state=a+b%26c%3Dd%2Be%2520%23f
    Nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
    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=yszLCapl%2F8cy8sUDNxDVgKMIe39wqEtJTNMC%2BD%2B7pTsRpr5a9t%2FG5%2BvhGpuLnKF5KcPnkKb%2F3mP2VyZJJVv0rE6R9Zba4iS3IjI%2FHznAiGY%2BTiR7Rs1EQ%2FjDrHRyeM0XwMo%3D"}]}
    Server: cloudflare
    Server-Timing: cfCacheStatus;desc="DYNAMIC"
    Server-Timing: cfEdge;dur=3,cfOrigin;dur=196
    Speculation-Rules: "/cdn-cgi/speculation"
    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
    
    <a href="https://protocolsoup.com/callback?error=invalid_scope&amp;error_description=None+of+the+requested+scopes+are+permitted+for+this+client&amp;iss=https%3A%2F%2Fprotocolsoup.com%2Foauth2&amp;state=a+b%26c%3Dd%2Be%2520%23f">Found</a>.
    
    

Tests

Implementation

Explainer

What this requires

Yes: an authorization error response that is delivered to the client by redirect returns the request's state, unchanged. The rule is the same as for a successful response and is stated separately in Section 4.1.2.1 so that the error path is not forgotten.

It applies to errors that are delivered to the client. An error that is shown to the user instead, because the client or redirection URI could not be validated, has no redirect to carry it.

Why it exists

The client's callback receives successes and failures at the same URL. It needs state on both to find the pending request the response belongs to and to confirm the response came through the browser session that started it. An error without state cannot be matched to anything. A client that accepted unmatched errors would let a third party cancel a user's login by sending the browser to the callback with an invented error.

What non-compliance looks like

Error paths are written after the success path and tend to be thinner. The redirect helper for errors takes the code and description and nobody passes it the state. Or the state is included but built by string concatenation, so a value containing & or # cuts the URL short.

How ProtocolSoup tests it

/oauth2/authorize uses one function for query errors and one for fragment errors, and both set state whenever the request had exactly one. A request that repeats state gets an error with none, since there is no single value to return.

TestAuthorizationResponseReturnsTheExactState requests a scope the client is not registered for, with a state containing a space, +, &, =, /, %20, ?, #, a double quote, angle brackets and a non-ASCII letter. The redirect must carry error=invalid_scope and a single state that decodes to the original.

A passing exchange is not captured, since the requirement constrains an error response. The failing one, state-in-the-error-response, has public-app request scope=api:read with the state a b&c=d+e%20#f. The recorded 302 carries error=invalid_scope and that state, percent-encoded, in the query of the redirect URI.

Related requirements

All RFC 6749 requirements · OAuth 2.0 protocol page

Does an authorization error response return the state parameter the client sent? · RFC 6749 §4.1.2.1 | ProtocolSoup