クライアント認証に失敗したときの応答
クライアント認証に失敗したとき、認可サーバーは invalid_client を返します。ただし HTTP ステータスが 400 か 401 か、WWW-Authenticate ヘッダーを付けるかどうかは、どのエンドポイントかとクライアントがどの方式で認証しようとしたかで変わります。このドキュメントでは、複数の RFC にまたがるこのルールを整理します。
どの RFC が何を決めているか
クライアント認証をするエンドポイントは、どれもエラーの形を RFC 6749 §5.2 に合わせます。ただし Introspection と CIBA は、invalid_client のステータスを自分の仕様で 401 に決めています。
| エンドポイント | 根拠 | 原文 |
|---|---|---|
| トークン | RFC 6749 §5.2 | 次の節 |
| Revocation | RFC 7009 §2.2.1 | "The error presentation conforms to the definition in Section 5.2 of [RFC6749]." |
| PAR | RFC 9126 §2.3 | "the authorization server returns an error response with the same format as is specified for error responses from the token endpoint in Section 5.2 of [RFC6749]" |
| CIBA | CIBA Core 1.0 §13 | "HTTP 401 Unauthorized: invalid_client — Client authentication failed (e.g., invalid client credentials, unknown client, no client authentication included, or unsupported authentication method)." |
| Introspection | RFC 7662 §2.3 | "If the protected resource uses OAuth 2.0 client credentials to authenticate to the introspection endpoint and its credentials are invalid, the authorization server responds with an HTTP 401 (Unauthorized) as described in Section 5.2 of OAuth 2.0 [RFC6749]." |