> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# トークンの取得

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

## エンドポイント

`POST /oauth/token`

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

### レスポンス

#### 200

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

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

### 詳細情報

* [クライアント認証情報フロー](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)

## ヘッダー

**DPoP** `string`

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

## Body Parameters

リクエスト本文は `application/x-www-form-urlencoded` 形式です。

**grant\_type** `string` *required*

使用するフローを示します。クライアント認証情報 の場合は `client_credentials` を使用します。

使用可能な値: `client_credentials`

**client\_id** `string` *required*

アプリケーションの クライアント ID。

**client\_secret** `string` *required*

アプリケーションの クライアントシークレット。

**audience** `string` *required*

アクセスする対象 API の一意の識別子。

**resource** `string`

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

**organization** `string`

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

## レスポンススキーマ

\{}

application/json

**access\_token** `string`

アクセストークン。

**token\_type** `string`

トークンの種類。通常は `Bearer`。

**expires\_in** `integer`

アクセストークンの有効期限 (秒) 。

## エージェントのアクセストークン

> [!WARNING]
>
> **Agent as Principal機能は現在、[早期アクセス](/docs/docs/troubleshoot/product-lifecycle/product-release-stages)です。**
>
> 参加をご希望の場合は、Auth0 Supportまでお問い合わせください。
>
> この機能を使用することにより、Oktaの該当する無料トライアル規約および[Master Subscription Agreement](https://www.okta.com/legal)に同意したものとみなされます。

リクエスト元のアプリケーションがエージェントにリンクされ、対象の 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/docs/ja-jp/secure/tokens/access-tokens/access-token-profiles#claims)を参照してください。

## レスポンスメッセージ

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