> ## Documentation Index
> Fetch the complete documentation index at: https://developers.authlete.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PKCE における S256 指定の強制化

> Authlete の機能を使用して、クライアントアプリケーションからの PKCE を利用した認可リクエストについて S256 の指定を強制するための設定手順を説明します。

<Info>
  For **Authlete 2.x** documentation, see [2.x version](/ja/v2/configuration-reference/endpoints/requiring-clients-to-specify-s256-when-using-pkce).
</Info>

Authlete には、OAuth 2.0 クライアントが認可リクエストで [PKCE (RFC 7636)](/ja/protocols-and-flows/protocol-extensions/proof-key-for-code-exchange-pkce) を利用する際に、「**code\_challenge\_method**」パラメーターの値として「**S256**」の指定を強制する機能があります。

サービスのクライアントに対して `PKCE` 利用時の `S256` を強制するには、次の手順を実施します。

1. 「クライアント設定」>「エンドポイント」>「認可」>「一般」に移動します。

2. 「認可コード交換用証明キー（PKCE）」の下にある「コードチャレンジメソッドとしてS256を使うことを必須にする」オプションを有効にします。（デフォルトでは無効になっています）

3. 「変更を保存」をクリックして更新を適用します。

<img src="https://mintcdn.com/authlete/TIo7ciy5bMLP5_Rt/ja/configuration-reference/endpoints/requiring-s256_ja.png?fit=max&auto=format&n=TIo7ciy5bMLP5_Rt&q=85&s=29a4baa256ce56444f0c1d3e5db062e5" alt="requiring-s256_1" width="1440" height="1500" data-path="ja/configuration-reference/endpoints/requiring-s256_ja.png" />

*「コードチャレンジメソッドとしてS256を使うことを必須にする」の設定*

この設定を有効にすると、対象の Authlete サービスの [POST /auth/authorization](/api-reference/authorization-endpoint/process-authorization-request) API は、`code_challenge_method=S256` を含まない認可リクエストをすべて拒否するようになります。

次の例は、`PKCE` を利用しているものの「`code_challenge_method=plain`」を含んでいる認可リクエストが、Authlete によって処理を拒否される様子を示しています（読みやすさのため折り返しています）。

**認可リクエスト**

```text theme={null}
% curl -s -X POST .../auth/authorization
  -H "Authorization: Bearer <Service Access Token e.g., Xg6jVpJCvsaXvy2ks8R5WzjdMYlvQqOym3slDX0wNhQ>' \
  -H 'Content-Type: application/json' \
  -d '{ "parameters": "redirect_uri=...
    &response_type=code
    &client_id=...
    &scope=...
    &code_challenge=...
    &code_challenge_method=plain" }'
```

**認可レスポンス**

```json theme={null}
{
  "resultCode": "A124308",
  "resultMessage": "[A124308] The value of the 'code_challenge_method' request parameter must be 'S256'.",
  ...
}
```
