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

# トークンの取得

> マシン間認証用のアクセストークンを、クライアント認証情報フロー を使用してリクエストします。

export const ReleaseStageNotice = ({feature, stage, plans, contact, terms}) => {
  const stageTextMap = {
    "beta": "Beta",
    "ea": "早期アクセス"
  };
  const stageText = stageTextMap[stage] || "製品リリース段階";
  const prsLink = "/docs/troubleshoot/product-lifecycle/product-release-stages";
  const linkify = (text, url) => {
    return <a href={url} target="_blank" rel="noreferrer" class="link">{text}</a>;
  };
  const includeDetails = (plans, contact, terms) => {
    const hasDetails = terms || plans || contact;
    if (!hasDetails) return null;
    return <span data-as="p">
            {plans && <>この機能は{linkify(`${plans}プラン`, "https://auth0.com/pricing")}でご利用いただけます。 </>}
            {contact && "参加をご希望の場合は、" + contact + "までお問い合わせください。 "}
            {terms && <>この機能を使用することにより、Oktaの該当する無料トライアル規約および{linkify("Master Subscription Agreement", "https://www.okta.com/legal")}に同意したものとみなされます。</>}
        </span>;
  };
  return <Warning>
            <span data-as="p">
                <strong>{feature}機能は現在、{linkify(stageText, prsLink)}です。</strong>
            </span>

            {includeDetails(plans, contact, terms)}
        </Warning>;
};

export const ResponseSchema = ({statusCode, type = "{}", children}) => {
  const [open, setOpen] = useState(false);
  return <div className="border border-gray-100 dark:border-gray-800 rounded-lg mb-3 overflow-hidden">
      <div className={`flex items-center gap-2.5 px-4 py-2.5 cursor-pointer select-none ${open ? "bg-gray-50 dark:bg-gray-800" : ""}`} onClick={() => setOpen(!open)}>
        {statusCode && <span className="border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 font-mono text-xs px-1.5 py-0.5 rounded">
            {statusCode.startsWith("default") ? "default" : statusCode}
          </span>}
        <span className="text-gray-500 dark:text-gray-400 text-sm font-mono">
          {type}
        </span>
        <span className="text-gray-400 dark:text-gray-500 text-sm italic">
          application/json
        </span>
        <svg className={`ml-auto opacity-50 transition-transform duration-200 ${open ? "rotate-180" : ""}`} width="16" height="16" viewBox="0 0 16 16" fill="none">
          <path d="M4 6l4 4 4-4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
        </svg>
      </div>
      {open && <div className="px-4 pt-1 pb-3 border-t border-gray-100 dark:border-gray-800">
          {children}
        </div>}
    </div>;
};

<div id="endpoint">
  ## エンドポイント
</div>

`POST /oauth/token`

これは、サーバープロセスが API にアクセスするために使用する OAuth 2.0 のグラントです。アプリケーションの認証情報 (クライアント ID とクライアントシークレット) を使ってアクセストークンを直接リクエストするには、このエンドポイントを使用します。

<div id="responses">
  ### レスポンス
</div>

<div id="200">
  #### 200
</div>

成功すると、アクセストークンが返されます。

```json theme={null}
{
  "access_token":"eyJz93a...k4laUWw",
  "token_type":"Bearer",
  "expires_in":86400
}
```

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

* [クライアント認証情報フロー](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow)
* [クライアント認証情報フローを使用してAPIを呼び出す](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow/call-your-api-using-the-client-credentials-flow)
* [Management Dashboardを使用したクライアントグラントの設定](https://auth0.com/docs/get-started/applications/update-grant-types)
* [Client Credentials Grant のアクセストークンをリクエストする](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow/call-your-api-using-the-client-credentials-flow)

<div id="headers">
  ## ヘッダー
</div>

<ParamField header="DPoP" type="string">
  リクエスト用の DPoP プルーフです。これは任意で、アプリケーションで Demonstrating Proof-of-Possession を使用している場合にのみ必要です。
</ParamField>

<div id="body-parameters">
  ## Body Parameters
</div>

<div className="prose-sm prose-gray dark:prose-invert">
  <span data-as="p">リクエスト本文は `application/x-www-form-urlencoded` 形式です。</span>
</div>

<ParamField body="grant_type" type="string" required>
  使用するフローを示します。クライアント認証情報 の場合は `client_credentials` を使用します。

  使用可能な値: `client_credentials`
</ParamField>

<ParamField body="client_id" type="string" required>
  アプリケーションの クライアント ID。
</ParamField>

<ParamField body="client_secret" type="string" required>
  アプリケーションの クライアントシークレット。
</ParamField>

<ParamField body="audience" type="string" required>
  アクセスする対象 API の一意の識別子。
</ParamField>

<ParamField body="resource" type="string">
  アクセスする対象 API (リソースサーバー) の識別子です。Auth0 テナントに登録されている API Identifier と一致している必要があります。テナントの [Resource Parameter Compatibility Profile](https://auth0.com/docs/get-started/tenant-settings#settings-advanced) が `compatibility` に設定されている場合、`audience` の代わりに使用されます。
</ParamField>

<ParamField body="organization" type="string">
  \[推奨]リクエストに関連付ける組織またはその識別子。詳しくは、[Machine-to-Machine Access for Organizations](https://auth0.com/docs/manage-users/organizations/organizations-for-m2m-applications) を参照してください。
</ParamField>

<div id="response-schema">
  ## レスポンススキーマ
</div>

<ResponseSchema>
  <ResponseField name="access_token" type="string">
    アクセストークン。
  </ResponseField>

  <ResponseField name="token_type" type="string">
    トークンの種類。通常は `Bearer`。
  </ResponseField>

  <ResponseField name="expires_in" type="integer">
    アクセストークンの有効期限 (秒) 。
  </ResponseField>
</ResponseSchema>

<div id="agent-access-tokens">
  ## エージェントのアクセストークン
</div>

<ReleaseStageNotice feature="Agents as Principal" stage="ea" contact="Auth0 Support" terms="true" />

リクエスト元のアプリケーションがエージェントにリンクされ、対象の API でエージェントの subject クレームが有効になっている場合、発行されるアクセストークンではエージェントが subject として識別されます。

* `sub` クレームは、アプリケーションの クライアント ID ではなく、エージェント識別子 (例: `agt_72jbvv7LfRKYp59gtRLtkn`) になります。
* トークンには、`sub_profile: "ai_agent"` と `client_profile: "service ai_agent"` が含まれます。

エージェントの subject クレームが有効な API を呼び出す、エージェントではない Machine-to-Machine (M2M) アプリケーションでは、`sub` クレームは `@clients` サフィックスを除いたアプリケーションの クライアント ID になります。レスポンスオブジェクトのスキーマ (`access_token`、`token_type`、`expires_in`) は変更されません。これらは発行された JWT 内のクレームです。詳細については、[Access Token Profiles](/docs/ja-jp/secure/tokens/access-tokens/access-token-profiles#claims)を参照してください。

<div id="response-messages">
  ## レスポンスメッセージ
</div>

| Status | Description |
| ------ | ----------- |
| 200    | 成功レスポンス     |
