Skip to content

Commit f8fbeb7

Browse files
authored
Merge pull request #633 from koic/refine_the_token_endpoint_error_docs
[Doc] Bound the token endpoint error docs to what sets the readers
2 parents 26eabbc + de9d539 commit f8fbeb7

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎docs/_client/authorization.md‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,18 +268,22 @@ so the storage should expire entries older than `pending_authorization_max_age`,
268268
269269
### Token Endpoint Errors
270270

271-
When a token exchange or refresh fails, `MCP::Client::OAuth::Flow::AuthorizationError` includes the HTTP status and
272-
the authorization server's `error` and `error_description` from [RFC 6749 Section 5.2](https://www.rfc-editor.org/rfc/rfc6749#section-5.2).
271+
When the token endpoint answers a token exchange or refresh with a non-2xx response within the body cap,
272+
`MCP::Client::OAuth::Flow::AuthorizationError` includes the HTTP status and the authorization server's `error`
273+
and `error_description` from [RFC 6749 Section 5.2](https://www.rfc-editor.org/rfc/rfc6749#section-5.2).
273274
For example:
274275

275276
```text
276277
Token endpoint returned status 400. invalid_request: Client must not use multiple authentication methods
277278
```
278279

279280
The exception exposes `http_status`, `error`, and `error_description` readers for structured diagnostics. Missing or non-string
280-
diagnostic fields are `nil`; non-JSON responses retain the status-only message. Other authorization failures have `nil` readers.
281-
An `invalid_grant` response still raises `Flow::InvalidGrantError`, a subclass of `Flow::AuthorizationError`, so refresh-token
282-
recovery behavior is unchanged.
281+
diagnostic fields are `nil`, as are blank ones; non-JSON responses retain the status-only message.
282+
When the authorization server returns an error to the authorization callback ([RFC 6749 Section 4.1.2.1](https://www.rfc-editor.org/rfc/rfc6749#section-4.1.2.1)),
283+
`error` and `error_description` are set the same way, with `http_status` left `nil`; other authorization failures have `nil` readers.
284+
A token endpoint response whose raw `error` is exactly `invalid_grant` still raises `Flow::InvalidGrantError`, a subclass of
285+
`Flow::AuthorizationError`, so refresh-token recovery behavior is unchanged. The class follows the raw value
286+
while the `error` reader holds the sanitized one, so `error == "invalid_grant"` alone does not imply that class.
283287

284288
Diagnostic fields are limited to 128 characters for `error` and 512 for `error_description`, including a trailing `...` when
285289
truncated. Characters outside the RFC's printable ASCII set are replaced with spaces, and surrounding whitespace is removed.

0 commit comments

Comments
 (0)