> ## 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) + "*****マスク済み*****";
          }
          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 で作成されるすべてのアプリケーションは、[サードパーティアプリケーション](/ja/docs/get-started/applications/third-party-applications)であり、[強化されたセキュリティ制御](/ja/docs/get-started/applications/third-party-applications/security-controls)が適用されます。つまり、DCR クライアントには次の特性があります。

* クライアントID には `tpc_` プレフィックスが付与される
* 認可コードフローでは PKCE が必須
* `authorization_code` および `refresh_token` のグラントタイプのみをサポートする。`client_credentials` グラントタイプは DCR では使用できません。
* API には、明示的な[クライアントグラント](/ja/docs/get-started/applications/application-access-to-apis-client-grants)を介してのみアクセスできる
* 認証には、[ドメインレベルの接続](/ja/docs/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. [Dashboard > Settings > 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 アクセストークン](/ja/docs/secure/tokens/access-tokens/management-api-access-tokens) を参照してください。
  </Tab>
</Tabs>

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

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

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

デフォルト権限の設定方法については、[Configure Third-Party Applications](/ja/docs/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 が有効な callback 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_` 接頭辞が付いた一意の Application ID。認証フローを開始する際に使用します。                               |
| `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 を使用する認可コードフロー](/ja/docs/get-started/authentication-and-authorization-flow/authorization-code-flow-with-pkce) を開始できます。

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

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

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

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

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

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

<div id="permissive-mode-for-dcr">
  ## DCR のパーミッシブモード
</div>

2026 年 4 月より前からサードパーティアプリケーションを使用していた一部のお客様は、強化されたセキュリティ制御ではなく、従来の動作でアプリケーションが作成されるように DCR を設定できます。詳細については、[パーミッシブモードでの動的クライアント登録](/ja/docs/get-started/applications/third-party-applications/permissive-mode#dynamic-client-registration-in-permissive-mode) を参照してください。

<div id="learn-more">
  ## 関連情報
</div>

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