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

# トークンの取得

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

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>

* [Client Credentials フロー](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow)
* [Client Credentials フローを使用して 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)
* [クライアントクレデンシャルグラントのアクセストークンをリクエストする](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">
  ## ボディパラメーター
</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識別子と一致している必要があります。テナントの [Resource Parameter Compatibility Profile](https://auth0.com/docs/get-started/tenant-settings#settings-advanced) が `compatibility` に設定されている場合は、`audience` の代わりに使用します。
</ParamField>

<ParamField body="organization" type="string">
  \[推奨] リクエストに関連付ける組織または識別子。詳細については、[組織向けマシンツーマシンアクセス](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="response-messages">
  ## レスポンスメッセージ
</div>

| ステータス | 説明      |
| ----- | ------- |
| 200   | 成功レスポンス |
