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

> アプリケーションで JWT で保護された認可リクエスト (JAR) を設定する方法を学びます。

# JWT で保護された認可リクエスト (JAR) を設定する

export const AuthCodeBlock = ({filename, icon, language, highlight, children}) => {
  const [displayText, setDisplayText] = useState(children);
  const [copyText, setCopyText] = useState(children);
  const wrapperRef = React.useRef(null);
  useEffect(() => {
    let unsubscribe = null;
    function init() {
      if (!window.autorun || !window.rootStore) {
        return;
      }
      unsubscribe = window.autorun(() => {
        let processedChildrenForDisplay = children;
        let processedChildrenForCopy = children;
        for (const [key, value] of window.rootStore.variableStore.values.entries()) {
          const escapedKey = key.replaceAll(/[.*+?^${}()|[\]\\]/g, (String.raw)`\$&`);
          let displayValue = value;
          if (key === "{yourClientSecret}" && value !== "{yourClientSecret}") {
            displayValue = value.substring(0, 3) + "*****MASKED*****";
          }
          processedChildrenForDisplay = processedChildrenForDisplay.replaceAll(new RegExp(escapedKey, "g"), displayValue);
          processedChildrenForCopy = processedChildrenForCopy.replaceAll(new RegExp(escapedKey, "g"), value);
        }
        setDisplayText(processedChildrenForDisplay);
        setCopyText(processedChildrenForCopy);
      });
    }
    if (window.rootStore) {
      init();
    } else {
      window.addEventListener("adu:storeReady", init);
    }
    return () => {
      window.removeEventListener("adu:storeReady", init);
      unsubscribe?.();
    };
  }, [children]);
  useEffect(() => {
    if (!wrapperRef.current) return;
    const originalWriteText = navigator.clipboard.writeText.bind(navigator.clipboard);
    let isOverriding = false;
    const handleClick = e => {
      const button = e.target.closest('[data-testid="copy-code-button"]');
      if (!button || !wrapperRef.current.contains(button)) return;
      isOverriding = true;
      navigator.clipboard.writeText = text => {
        if (isOverriding) {
          isOverriding = false;
          navigator.clipboard.writeText = originalWriteText;
          return originalWriteText(copyText);
        }
        return originalWriteText(text);
      };
      setTimeout(() => {
        if (isOverriding) {
          isOverriding = false;
          navigator.clipboard.writeText = originalWriteText;
        }
      }, 100);
    };
    const wrapper = wrapperRef.current;
    wrapper.addEventListener('click', handleClick, true);
    return () => {
      wrapper.removeEventListener('click', handleClick, true);
      if (navigator.clipboard.writeText !== originalWriteText) {
        navigator.clipboard.writeText = originalWriteText;
      }
    };
  }, [copyText]);
  return <div ref={wrapperRef}>
      <CodeBlock filename={filename} icon={icon} language={language} lines highlight={highlight}>
        {displayText}
      </CodeBlock>
    </div>;
};

export const codeExample1 = `POST https://{yourTenant}.auth0.com/api/v2/clients/{yourClientId}/credentials
  Authorization: Bearer <YOUR_ACCESS_TOKEN>
  Content-Type: application/json
  {
    "name": "JAR向けの資格情報",
    "credential_type": "public_key",
    "pem": "[YOUR PEM FILE CONTENT]",
    "alg": "RS256"
  }`;

export const codeExample2 = `PATCH https://{yourTenant}.auth0.com/api/v2/clients/{yourClientId}
Authorization: Bearer <YOUR_ACCESS_TOKEN>
Content-Type: application/json
{
  "signed_request_object": {
    "credentials": [{"id": "[YOUR CREDENTIAL ID]"}]
  }
}`;

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  Highly Regulated Identity 機能を使用するには、Highly Regulated Identity アドオンを含む Enterprise プランが必要です。詳しくは、[Auth0 Pricing](https://auth0.com/pricing/)を参照してください。
</Callout>

<Tooltip tip="JSON Web トークン (JWT): 2 者間でクレームを安全にやり取りするための標準的な ID トークン形式（多くの場合、アクセス トークン形式としても使用）。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=JWT">JWT</Tooltip>-Secured Authorization Requests (JAR) では、OAuth 2.0 の認可リクエストパラメーターを 1 つの JWT リクエストパラメーターにまとめ、完全性を保護するために署名できます。

<h2 id="prerequisites">
  前提条件
</h2>

JAR を使用するようにアプリケーションを設定する前に、[RSA キーペアを生成する](/docs/ja-jp/secure/application-credentials/generate-rsa-key-pair)必要があります。

<Warning>
  資格情報の用途ごとに、別々のキーペアを生成してください。たとえば、JAR と Private Key JWT 認証の両方に同じキーペアを使い回さないでください。
</Warning>

<h2 id="configure-jar-for-an-application">
  アプリケーションのJARを設定する
</h2>

アプリケーションのJARは、<Tooltip tip="Auth0 Dashboard: サービスを設定するためのAuth0の主要なプロダクトです。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=Auth0+Dashboard">Auth0 Dashboard</Tooltip> と <Tooltip tip="Auth0 Dashboard: サービスを設定するためのAuth0の主要なプロダクトです。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=Management+API">Management API</Tooltip> を使用して設定できます。

<Tabs>
  <Tab title="Auth0 Dashboard">
    Auth0 Dashboard を使用して、事前に生成した RSA キーで JAR を使用するようにアプリケーションを設定します。

    1. [Auth0 Dashboard > アプリケーション](https://manage.auth0.com/#/applications) に移動します。
    2. JAR で使用するアプリケーションを選択します。
    3. **Application Settings** タブを選択します。
    4. **Authorization Requests** セクションで、**Require JWT-Secured Authorization Requests** を有効にします。
    5. 資格情報が割り当てられておらず、利用可能な資格情報がある場合は、既存の資格情報を割り当てるよう求められます。

           <Frame>
             <img src="https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/HQHhFWTtdfNa5TnZ1dwx6/e47068cc9e85c538f80476162f4314a3/Existing_Creds_-_English.png?fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=c2ec97f5dcacd37a35faa91f70f0498d" alt="Auth0 Dashboard > アプリケーション > 設定 > 既存の資格情報を割り当てる" data-og-width="792" width="792" data-og-height="688" height="688" data-path="docs/images/cdy7uua7fh8z/HQHhFWTtdfNa5TnZ1dwx6/e47068cc9e85c538f80476162f4314a3/Existing_Creds_-_English.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/HQHhFWTtdfNa5TnZ1dwx6/e47068cc9e85c538f80476162f4314a3/Existing_Creds_-_English.png?w=280&fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=f29742f491361d77717a415b29dc781f 280w, https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/HQHhFWTtdfNa5TnZ1dwx6/e47068cc9e85c538f80476162f4314a3/Existing_Creds_-_English.png?w=560&fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=f32472274fa9aa9644d1837bed55a631 560w, https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/HQHhFWTtdfNa5TnZ1dwx6/e47068cc9e85c538f80476162f4314a3/Existing_Creds_-_English.png?w=840&fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=671a9fc42666312033a4671e7193151e 840w, https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/HQHhFWTtdfNa5TnZ1dwx6/e47068cc9e85c538f80476162f4314a3/Existing_Creds_-_English.png?w=1100&fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=25261f9c1eaa450c74c5241833ea559d 1100w, https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/HQHhFWTtdfNa5TnZ1dwx6/e47068cc9e85c538f80476162f4314a3/Existing_Creds_-_English.png?w=1650&fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=b94d7d4aa815ae68e4914d8f56d58fe2 1650w, https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/HQHhFWTtdfNa5TnZ1dwx6/e47068cc9e85c538f80476162f4314a3/Existing_Creds_-_English.png?w=2500&fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=5a0ff5f9c762d5b868077243b9ecab53 2500w" />
           </Frame>
    6. 新しい資格情報を割り当てることもできます。

           <Frame>
             <img src="https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/7JfsCBwytWO6Q7hUvdtSwJ/b85fd39fea7330a31496f51347767ae7/New_Creds_-_EN.png?fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=5ce284a801c98160e553eb2708bd30cf" alt="Auth0 Dashboard > アプリケーション > 設定 > 新しい資格情報を割り当てる" data-og-width="702" width="702" data-og-height="366" height="366" data-path="docs/images/cdy7uua7fh8z/7JfsCBwytWO6Q7hUvdtSwJ/b85fd39fea7330a31496f51347767ae7/New_Creds_-_EN.png" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/7JfsCBwytWO6Q7hUvdtSwJ/b85fd39fea7330a31496f51347767ae7/New_Creds_-_EN.png?w=280&fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=696babdef86e3f751cfd13e1a6558824 280w, https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/7JfsCBwytWO6Q7hUvdtSwJ/b85fd39fea7330a31496f51347767ae7/New_Creds_-_EN.png?w=560&fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=4361f2db9dbb456496947c3accdc45fb 560w, https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/7JfsCBwytWO6Q7hUvdtSwJ/b85fd39fea7330a31496f51347767ae7/New_Creds_-_EN.png?w=840&fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=2d4bce46fb4179be35c82169e2b6c4d2 840w, https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/7JfsCBwytWO6Q7hUvdtSwJ/b85fd39fea7330a31496f51347767ae7/New_Creds_-_EN.png?w=1100&fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=e76a38d52bda2ba6ef1fe65db594aa80 1100w, https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/7JfsCBwytWO6Q7hUvdtSwJ/b85fd39fea7330a31496f51347767ae7/New_Creds_-_EN.png?w=1650&fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=6666cc4dc685ecb7aca8683420840b7a 1650w, https://mintcdn.com/docs-dev-feat-init-gt-translations/ZmqODkbyV9Q5Sot2/docs/images/cdy7uua7fh8z/7JfsCBwytWO6Q7hUvdtSwJ/b85fd39fea7330a31496f51347767ae7/New_Creds_-_EN.png?w=2500&fit=max&auto=format&n=ZmqODkbyV9Q5Sot2&q=85&s=4b66c380eb98989703c61715e21f2700 2500w" />
           </Frame>
    7. 事前に生成した RSA キーペアをアップロードして、新しい資格情報を追加し、割り当てます。求められたら、次の内容を入力します。

       * **Name**: 資格情報を識別するための名前
       * **Public Key**: PEM 形式の X.509 証明書の公開キー
       * **Algorithm**: JAR の署名アルゴリズムを選択
       * **Expiration Date**: 資格情報の有効期限を設定
  </Tab>

  <Tab title="Management API">
    [Management API](https://auth0.com/docs/api/management/v2) を使用して、`signed_request_object` クライアント設定プロパティでアプリケーションの JAR を設定します。このオブジェクトプロパティには、次のフィールドが含まれます。

    * `required`: `/authorize` および `/oauth/par` へのすべての認可リクエストで JAR の使用を必須にします。詳しくは、[JWT で保護された認可リクエストを使用する認可コードフロー](/docs/ja-jp/get-started/authentication-and-authorization-flow/authorization-code-flow/authorization-code-flow-with-jar) を参照してください。
    * `credentials`: 署名の検証に使用する資格情報 ID の配列です。

    <Callout icon="file-lines" color="#0EA5E9" iconType="regular">
      `credentials` パラメーターは、Private Key JWT パラメーター `client_authentication_methods.private_key_jwt.credentials` と同様に動作し、新しいアプリケーションの作成時に資格情報の作成をサポートします。詳しくは、[Private Key JWT を設定する](/docs/ja-jp/get-started/applications/configure-private-key-jwt) を参照してください。
    </Callout>

    Management API を使用すると、新しいアプリケーションまたは既存のアプリケーションに対して JAR を設定できます。

    <h4 id="configure-jar-for-a-new-application">
      新しいアプリケーションに JAR を設定する
    </h4>

    新しいアプリケーションを作成するときは、`signed_request_object` を含む POST リクエストを送信して JAR を設定します。その POST リクエストでは、対応するクライアント資格情報 (つまりキー PEM) も登録できます。

    ```json lines theme={null}
    POST https://{yourTenant}.auth0.com/api/v2/clients
    Authorization: Bearer <YOUR_ACCESS_TOKEN>
    Content-Type: application/json
    {
      "name": "My App using JAR",
      "signed_request_object": {
          "required": true,
    "credentials": [{
            "name": "My credential for JAR",
            "credential_type": "public_key",
            "pem": "[YOUR PEM FILE CONTENT]",
            "alg": "RS256"
    }]
      },
      "jwt_configuration": {
        "alg": "RS256"
      }
    }
    ```

    <h4 id="configure-jar-for-an-existing-application">
      既存のアプリケーションに JAR を設定する
    </h4>

    既存のアプリケーションを更新する場合は、まずクライアント資格情報を明示的に作成する必要があります。次の POST リクエストでは、PEM ファイルの内容を使用して JAR 用のクライアント資格情報を作成します。

    <AuthCodeBlock children={codeExample1} language="json" />

    <Callout icon="file-lines" color="#0EA5E9" iconType="regular">
      改行が余分な書式なしで適切に JSON エンコードされていることを確認してください。
    </Callout>

    次に、クライアント資格情報を `signed_request_object` クライアント設定に割り当てます。次の PATCH リクエストは、クライアント資格情報を `signed_request_object` に関連付けます。

    <AuthCodeBlock children={codeExample2} language="json" />
  </Tab>
</Tabs>

<h2 id="learn-more">
  詳しくはこちら
</h2>

* [JWT で保護された認可リクエスト (JAR) を使用する認可コードフロー](/docs/ja-jp/get-started/authentication-and-authorization-flow/authorization-code-flow/authorization-code-flow-with-jar)
