> ## 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.

> Auth0 でサードパーティアプリケーションを動的に登録する方法を説明します。

# 動的クライアント登録

export const AuthCodeGroup = ({children, dropdown}) => {
  const [processedChildren, setProcessedChildren] = useState(children);
  useEffect(() => {
    let unsubscribe = null;
    function init() {
      unsubscribe = window.autorun(() => {
        const processChildren = node => {
          if (typeof node === "string") {
            let processedNode = node;
            for (const [key, value] of window.rootStore.variableStore.values.entries()) {
              const escapedKey = key.replaceAll(/[.*+?^${}()|[\]\\]/g, (String.raw)`\$&`);
              processedNode = processedNode.replaceAll(new RegExp(escapedKey, "g"), value);
            }
            return processedNode;
          } else if (Array.isArray(node)) {
            return node.map(processChildren);
          } else if (node && node.props && node.props.children) {
            return {
              ...node,
              props: {
                ...node.props,
                children: processChildren(node.props.children)
              }
            };
          }
          return node;
        };
        setProcessedChildren(processChildren(children));
      });
    }
    if (window.rootStore) {
      init();
    } else {
      window.addEventListener("adu:storeReady", init);
    }
    return () => {
      window.removeEventListener("adu:storeReady", init);
      unsubscribe?.();
    };
  }, [children]);
  return <CodeGroup dropdown={dropdown}>{processedChildren}</CodeGroup>;
};

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>;
};

テナント向けにサードパーティアプリケーションを動的に登録できます。Dynamic Client Registration (DCR) は、[OpenID Connect Dynamic Client Registration specification](https://openid.net/specs/openid-connect-registration-1_0.html) に基づいています。

Dynamic Client Registration で作成されたすべてのアプリケーションは、[サードパーティアプリケーション](/docs/ja-jp/get-started/applications/third-party-applications)として扱われ、[強化されたセキュリティ制御](/docs/ja-jp/get-started/applications/third-party-applications/security-controls)が適用されます。つまり、DCR クライアントには次の制限があります。

* クライアント ID に `tpc_` プレフィックスが付与される
* 認可コードフローでは PKCE が必須
* サポートされるグラントタイプは `authorization_code` と `refresh_token` のみ。`client_credentials` グラントタイプは DCR では利用できません。
* API へのアクセスは、明示的な[クライアントグラント](/docs/ja-jp/get-started/applications/application-access-to-apis-client-grants)を通じてのみ可能
* 認証には[ドメインレベルの接続](/docs/ja-jp/authenticate/identity-providers/promote-connections-to-domain-level)のみ使用可能

<div id="enable-dynamic-client-registration">
  ## Dynamic Client Registration を有効にする
</div>

<Warning>
  Auth0 は Open Dynamic Registration をサポートしています。これを有効にすると、トークンなしで誰でもあなたのテナントにアプリケーションを作成できるようになります。
</Warning>

デフォルトでは、Dynamic Client Registration はすべてのテナントで無効になっています。Dynamic Client Registration を有効にするには、Auth0 Dashboard または Management API を使用します。

<Tabs>
  <Tab title="Auth0 Dashboard">
    1. [Auth0 Dashboard > 設定 > Advanced](https://manage.auth0.com/#/tenant/advanced) に移動し、**Dynamic Client Registration (DCR)** を有効にします。
  </Tab>

  <Tab title="Management API">
    [`/api/v2/tenants/settings`](https://auth0.com/docs/api/management/v2#!/Tenants/patch_settings) エンドポイントを使用して、テナント設定の `enable_dynamic_client_registration` フラグを `true` に設定します。

    <AuthCodeGroup>
      ```bash cURL theme={null}
      curl --request PATCH \
        --url 'https://{yourDomain}/api/v2/tenants/settings' \
        --header 'authorization: Bearer {YOUR_MANAGEMENT_API_TOKEN}' \
        --header 'content-type: application/json' \
        --data '{ "flags": { "enable_dynamic_client_registration": true } }'
      ```
    </AuthCodeGroup>

    `{YOUR_MANAGEMENT_API_TOKEN}` は、`update:tenant_settings` スコープを持つ有効なトークンに置き換える必要があります。詳しくは、[Management API アクセストークン](/docs/ja-jp/secure/tokens/access-tokens/management-api-access-tokens) を参照してください。
  </Tab>
</Tabs>

<div id="configure-api-access-for-dcr-clients">
  ## DCR クライアントの API アクセスを設定する
</div>

DCR を有効にする前に、動的に登録されるクライアントがアクセスする API で、[サードパーティアプリケーションのデフォルト権限](/docs/ja-jp/get-started/applications/application-access-to-apis-client-grants#default-permissions-for-third-party-applications)を設定してください。デフォルト権限がないと、DCR クライアントはどの API にもアクセスできません。

デフォルト権限では、すべてのサードパーティアプリケーションが自動的に利用できる API とスコープの基本セットを定義します。DCR では登録フロー中にアプリケーションごとのクライアントグラントを設定できないため、これは不可欠です。

デフォルト権限の設定方法については、[サードパーティアプリケーションを設定する](/docs/ja-jp/get-started/applications/third-party-applications/configure-third-party-applications#default-permissions-for-all-third-party-applications)を参照してください。

<div id="register-an-application">
  ## アプリケーションを登録する
</div>

アプリケーションを動的に登録するには、`/oidc/register` エンドポイントに `POST` リクエストを送信します。Auth0 は Open Dynamic Registration をサポートしているため、`/oidc/register` エンドポイントはアクセストークンなしでも登録リクエストを受け付けます。

<AuthCodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://{yourDomain}/oidc/register' \
    --header 'content-type: application/json' \
    --data '{
      "client_name": "My Dynamic Application",
      "redirect_uris": ["https://application.example.com/callback"],
      "token_endpoint_auth_method": "none",
      "grant_types": ["authorization_code", "refresh_token"],
      "response_types": ["code"]
    }'
  ```
</AuthCodeGroup>

| **パラメーター**                   | **説明**                                                                                                                                |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `client_name`                | 作成するアプリケーションの名前です。                                                                                                                    |
| `redirect_uris` (required)   | 認証フローの最後に、Auth0 が有効なコールバック URL として受け入れる URL の配列です。                                                                                    |
| `token_endpoint_auth_method` | トークンエンドポイントの認証方法です。パブリッククライアント (SPA、Native) の場合は `none`、機密クライアントの場合は `client_secret_post` (デフォルト) を使用します。                             |
| `grant_types`                | アプリケーションで使用するグラントタイプです。レスポンスでは、使用が許可されているものだけが返されるように絞り込まれます。DCR を通じて作成されたアプリケーションでは、`authorization_code` と `refresh_token` をサポートします。 |
| `response_types`             | アプリケーションで使用するレスポンスタイプです。認可コードフローでは `code` を使用します。                                                                                     |

成功すると、Auth0 はアプリケーションの資格情報を返します。

```json theme={null}
{
  "client_name": "My Dynamic Application",
  "client_id": "tpc_8SXWY6j3afl2CP5ntwEOpMdPxxy49Gt2",
  "client_secret": "Q5O...33P",
  "redirect_uris": [
    "https://application.example.com/callback"
  ],
  "client_secret_expires_at": 0,
  "grant_types": ["authorization_code", "refresh_token"],
  "token_endpoint_auth_method": "none"
}
```

| **フィールド**                  | **説明**                                                                       |
| -------------------------- | ---------------------------------------------------------------------------- |
| `client_id`                | `tpc_` プレフィックスが付いた一意のアプリケーション識別子です。認証フローを開始するときに使用します。                       |
| `client_secret`            | 機密クライアント用のアプリケーションシークレットです。`token_endpoint_auth_method` が `none` の場合は返されません。 |
| `client_secret_expires_at` | クライアントシークレットの有効期限です。Auth0 では常に `0` (期限なし) です。                                |

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  サードパーティの開発者は、登録後にアプリケーション設定を変更できません。変更が必要な場合は、テナントの所有者に連絡する必要があります。
</Callout>

登録後、アプリケーションは `client_id` と設定された `redirect_uris` を使用して、[PKCE を使用した Authorization Code フロー](/docs/ja-jp/get-started/authentication-and-authorization-flow/authorization-code-flow-with-pkce) を開始できます。

<div id="tenant-access-control-list-acl">
  ## テナントアクセス制御リスト (ACL)
</div>

Auth0 では、`/oidc/register` エンドポイントへのトラフィックを管理するための [テナントアクセス制御リスト (ACL)](/docs/ja-jp/secure/tenant-access-control-list) を提供しています。次の条件に基づいて ACL ルールを設定することで、DCR リクエストを送信できる相手を制限できます。

* 送信元 IP アドレスと CIDR 範囲
* 地理的位置
* その他のリクエストシグナル

DCR の ACL ルールを設定するには、ACL ルールに `dcr` スコープを追加します。詳しくは、[Tenant ACL Reference](/docs/ja-jp/secure/tenant-access-control-list/reference) をご覧ください。

<div id="rate-limits">
  ## レート制限
</div>

`/oidc/register` エンドポイントには、テナントごとに 1 秒あたり 5 リクエストのレート制限が適用されます。レート制限の詳細については、[レート制限の設定](/docs/ja-jp/troubleshoot/customer-support/operational-policies/rate-limit-policy/rate-limit-configurations)をご覧ください。

<div id="permissive-mode-for-dcr">
  ## DCR の許容モード
</div>

2026年4月以前からサードパーティアプリケーションを使用している一部のお客様は、強化されたセキュリティ制御ではなく、従来の動作を備えたアプリケーションを作成するように DCR を設定できます。詳しくは、[許容モードでの Dynamic Client Registration](/docs/ja-jp/get-started/applications/third-party-applications/permissive-mode#dynamic-client-registration-in-permissive-mode) をご覧ください。

<div id="learn-more">
  ## さらに詳しく
</div>

* [サードパーティアプリケーション](/docs/ja-jp/get-started/applications/third-party-applications)
* [サードパーティアプリケーション向けのセキュリティ制御](/docs/ja-jp/get-started/applications/third-party-applications/security-controls)
* [API へのアプリケーションアクセス: クライアントグラント](/docs/ja-jp/get-started/applications/application-access-to-apis-client-grants)
* [ファーストパーティアプリケーションとサードパーティアプリケーション](/docs/ja-jp/get-started/applications/first-party-and-third-party-applications)
* [ユーザーの同意とサードパーティアプリケーション](/docs/ja-jp/get-started/applications/third-party-applications/user-consent-and-third-party-applications)
