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

> Rich Authorization Requests (RAR) を Authorization Code Flow で使用する方法を説明します。

# Rich Authorization Requests (RAR) を使用した Authorization Code Flow

[Rich Authorization Requests (RAR)](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-rar) を使用すると、クライアントは、エンドユーザーなどの <Tooltip tip="リソースオーナー: 保護されたリソースへのアクセスを許可できるエンティティ（ユーザーやアプリケーションなど）。" cta="用語集を見る" href="/ja/docs/glossary?term=resource+owners">リソースオーナー</Tooltip> から <Tooltip tip="Fine-grained Authorization (FGA): 個々のユーザーに特定のオブジェクトまたはリソースへのアクセスを許可する Auth0 の製品。" cta="用語集を見る" href="/ja/docs/glossary?term=fine-grained+authorization">きめ細かな認可</Tooltip> データを要求し、取得できます。  クライアントは、Authorization Code Flow の一部として、RAR データを Pushed Authorization Request (PAR) endpoint に渡すことができます。詳細については、[Configure Pushed Authorization Requests](/ja/docs/get-started/applications/configure-par) を参照してください。

従来の <Tooltip tip="OAuth 2.0: 認可プロトコルとワークフローを定義する認可フレームワーク。" cta="用語集を見る" href="/ja/docs/glossary?term=OAuth+2.0">OAuth 2.0</Tooltip> フローでは、クライアントが [スコープ](/ja/docs/get-started/apis/scopes) を使用して <Tooltip tip="OAuth 2.0: 認可プロトコルとワークフローを定義する認可フレームワーク。" cta="用語集を見る" href="/ja/docs/glossary?term=resource+server">リソースサーバー</Tooltip> へのアクセスを要求すると、リソースオーナーはそれらのリソースへのアクセスをクライアントに許可します。Rich Authorization Request では、クライアントは `/par` endpoint に `authorization_details` パラメーターを渡すことで、スコープで要求するものよりもさらに細かな権限を要求できます。これにより、クライアントとリソースオーナーの双方がリソースへのアクセスをよりきめ細かく制御できるようになり、アクセスの過剰付与に伴うセキュリティリスクを軽減できます。

Auth0 では `authorization_details` の type の検証のみがサポートされるため、`authorization_details` 内の JSON オブジェクトについては自分で検証を実装する必要があります。詳細については、[Configure Rich Authorization Requests](/ja/docs/get-started/apis/configure-rich-authorization-requests) を参照してください。

<div id="how-it-works">
  ## 仕組み
</div>

Rich Authorization Request では、`authorization_details` パラメーターはオブジェクトの JSON 配列であり、各要素には文字列で表される `type` フィールドを含める必要があります。`type` フィールドは、オブジェクト内でカスタマイズできるフィールドを決定します。`authorization_details` 配列には、同じ `type` のエントリを複数含めることができます。`authorization_details` の `type` の登録方法の詳細については、[Configure Rich Authorization Requests](/ja/docs/get-started/apis/configure-rich-authorization-requests) を参照してください。

Auth0 は、ユーザーがカスタムの同意画面で認可できるように `authorization_details` を表示します。詳細については、[Set customized consent prompt](/ja/docs/get-started/apis/configure-rich-authorization-requests#set-customized-consent-prompt) を参照してください。

`authorization_details` パラメーターは `/par` エンドポイントに渡す必要があります。これにより、Auth0 の <Tooltip tip="認可サーバー: ユーザーのアクセス範囲の境界を定義するのに寄与する集中管理サーバーです。たとえば、認可サーバーはユーザーが利用できるデータ、タスク、機能を制御できます。" cta="用語集を表示" href="/ja/docs/glossary?term=Authorization+Server">認可サーバー</Tooltip> が `type` の早期検証を実行できるようになります。`/par` エンドポイントは、ブラウザーなどのフロントチャネルで機密データが漏えいするのを防ぐため、認可リクエストをバックチャネル経由で渡します。認可リクエストを `/par` エンドポイントに渡すと、アプリケーションは `/authorize` エンドポイントにリダイレクトし、その後 Authorization Code Flow に進みます。詳細については、[Authorization Code Flow with PAR](/ja/docs/get-started/authentication-and-authorization-flow/authorization-code-flow/authorization-code-flow-with-par) を参照してください。

Authorization Code Flow を完了するには、次の例のように `/oauth/token` エンドポイントで認可コードを交換します。

```http lines theme={null}
POST https://{YOUR_DOMAIN}.auth0.com/oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&client_id={YOUR_CLIENT_ID}&client_secret={YOUR_CLIENT_SECRET}&code={AUTHORIZATION_CODE}&redirect_uri=https://jwt.io
```

成功すると、<Tooltip tip="アクセストークン: API にアクセスするために使用される、不透明な文字列または JWT 形式の認可資格情報。" cta="用語集を表示" href="/ja/docs/glossary?term=access+token">アクセストークン</Tooltip> と `authorization_details` 配列を含むレスポンスを受け取ります。

```json lines theme={null}
{
  "access_token": "ey...ZQ",
  "expires_in": 86400,
  "authorization_details": [
{
  "type": "money_transfer", 
  "instructedAmount": {"amount": 2500, "currency": "USD"},   
  "sourceAccount": "xxxxxxxxxxx1234", 
  "destinationAccount": "xxxxxxxxxxx9876", 
  "beneficiary": "Hanna Herwitz", 
  "subject": "A Lannister Always Pays His Debts"
}
  ],
  "token_type": "Bearer"
}
```

[JWT のベストプラクティス](https://datatracker.ietf.org/doc/html/rfc9068#name-privacy-considerations)の一環として、クライアントは `authorization_details` を使用することで、アクセストークンを確認しなくても、自身に付与された認可のスコープを把握できます。要求された <Tooltip tip="Audience: 発行されたトークンの対象者を一意に識別する識別子。トークン内では aud という名前で表され、その値には、IDトークンの場合はアプリケーション（クライアントID）の ID、アクセストークンの場合は API（API 識別子）の ID が含まれます。" cta="用語集を見る" href="/ja/docs/glossary?term=audience">オーディエンス</Tooltip> が [JWE アクセストークン](/ja/docs/secure/tokens/json-web-tokens) を必要とする API の場合、`/oauth/token` エンドポイントは、`authorization_details` から `type` を除くすべてのオブジェクトフィールドを省略したレスポンスを返します。レスポンス内のアクセストークンのクレームには影響ありません。

```json lines theme={null}
{
  "iss": "https://my_tenant.auth0.com/",
  "sub": "auth0|me",
  "aud": "https://myapi.authzero.com",
  "iat": 1683661385,
  "exp": 1683747785,
  "azp": "my_client",
  "authorization_details": [
{
  "type": "money_transfer", 
  "instructedAmount": {"amount": 2500, "currency": "USD"},   
  "sourceAccount": "xxxxxxxxxxx1234", 
  "destinationAccount": "xxxxxxxxxxx9876", 
  "beneficiary": "Hanna Herwitz", 
  "subject": "A Lannister Always Pays His Debts"
}
  ]
}
```

<div id="configure-rar-for-the-authorization-code-flow">
  ## Authorization Code Flow 用に RAR を設定する
</div>

Authorization Code Flow で Rich Authorization Requests を設定する前に、以下を実施する必要があります。

* [カスタムドメイン](/ja/docs/customize/custom-domains) を作成する。
* [カスタム Universal Login Pages](/ja/docs/customize/login-pages/universal-login/customize-templates) テンプレートを作成する。<Tooltip tip="Universal Login: アプリケーションは、ユーザーの本人確認のために、Auth0 の認可サーバーでホストされる Universal Login にリダイレクトされます。" cta="用語集を見る" href="/ja/docs/glossary?term=Universal+Login">Universal Login</Tooltip> のページテンプレートをカスタマイズする方法については、[Page templates API](/ja/docs/customize/login-pages/universal-login/customize-templates#page-templates-api) のドキュメントを参照してください。

Authorization Code Flow で RAR を設定するには、以下が必要です。

* リソースサーバーの `authorization_details` タイプを登録する。
* カスタマイズした consent プロンプトを設定する。

詳しくは、[Rich Authorization Requests を設定する](/ja/docs/get-started/apis/configure-rich-authorization-requests) を参照してください。

<div id="access-authorization_details-in-actions">
  ## Actions で `authorization_details` にアクセスする
</div>

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  Auth0 は、Actions を使用した RAR の更新をサポートしていません。
</Callout>

Auth0 では、[post-login Action](/ja/docs/customize/actions/explore-triggers/signup-and-login-triggers/login-trigger/post-login-event-object) で `event.transaction.requested_authorization_details` プロパティを通じて `authorization_details` パラメーターを利用できます。Action ではこのプロパティを参照して、[MFA チャレンジ](/ja/docs/secure/highly-regulated-identity/transactional-authorization-with-authorization-code-flow#push-notifications) でユーザーにトランザクションの詳細を表示できます。

<div id="what-doesnt-auth0-support">
  ## Auth0 でサポートされていないこと
</div>

Auth0 では、次の機能はサポートされていません。

* Actions を使用した RAR の更新
* クライアントが検出できるように RAR タイプを公開すること
* API で許可されているタイプと一致する `type` プロパティを持っているかどうかの確認を超える、RAR オブジェクトの検証。詳細については、[RAR を設定する](/ja/docs/get-started/apis/configure-rich-authorization-requests)を参照してください。

<div id="learn-more">
  ## 詳細
</div>

* [Rich Authorization Requests (RAR) を設定する](/ja/docs/get-started/apis/configure-rich-authorization-requests)
