> ## 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 利用の強制化

> PKCE を利用するよう、クライアントに強制する設定を説明します。

Authlete では、クライアントからの認可リクエストに関し、[**PKCE (RFC 7636)**](/ja/protocols-and-flows/protocol-extensions/proof-key-for-code-exchange-pkce)
の利用を強制できます。

この機能を有効化するためには、サービス編集 → 「認可」タブ → 「認可エンドポイント」セクション にある「**コード交換用証明キー (RFC 7636)**」にて「要求する」を選択します。\
既定値は「要求しない」になっています。

<img src="https://mintcdn.com/authlete/NmFoIJ4VSX_LOgob/img/kb/ja/oauth-and-openid-connect/pkce-rfc-7636/requiring-pkce_1.png?fit=max&auto=format&n=NmFoIJ4VSX_LOgob&q=85&s=40e36d5cbdf87c000678086517a6e122" alt="requiring-pkce_1" width="906" height="1202" data-path="img/kb/ja/oauth-and-openid-connect/pkce-rfc-7636/requiring-pkce_1.png" />

*「コード交換用証明キー (RFC 7636) 」の設定*

「要求する」に設定された Authlete サービスでは、[/auth/authorization API](/api-reference/authorization-endpoint/process-authorization-request)
にて、**code\_challenge** を含まない認可リクエストの処理を拒否します。以下は処理例です（一部折り返しています）。

* リクエスト (code\_challenge を含まない認可リクエストを parameters に指定)

```shell theme={null}
curl -s -X POST .../auth/authorization \
    -u ... \
    -H 'Content-Type: application/json' \
    -d '{"parameters": "redirect_uri=...&response_type=code&client_id=...&scope=..."}'
```

* レスポンス (code\_challenge パラメーターが含まれていない旨を返却)

```json theme={null}
{
    "type": "authorizationResponse",
    "resultCode": "A124301",
    "resultMessage": 
      "[A124301] The authorization request does not contain
       'code_challenge' parameter. See RFC 7636 for details.",
    ...
}
```
