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

# ネイティブソーシャルのトークン交換

> note

`POST /oauth/token`

note
このフローは、ネイティブソーシャルのインタラクションで**のみ**使用することを意図しています。このフローをネイティブソーシャル設定外で使用することは、まったくお勧めしません。

ブラウザーベースでないソリューション（モバイルプラットフォームのSDKなど）がユーザーを認証する場合、認証は通常アーティファクトがアプリケーションコードに返されるという結果になります。このような場合、この付与タイプは、信頼できるソースからのアーティファクトを受け入れ、応答でトークンを発行することをAuth0プラットフォームに許可します。こうして、（ネイティブアプリで一般的な）ブラウザーベースでない認証メカニズムを使用するアプリは、ユーザーインタラクションを求める必要なく、Auth0トークンを取得できます。

このフローで返されるアーティファクト（およびそのコンテンツ）は、`subject_token_type`およびテナントの構成設定によって決まります。
備考

* アプリケーションに発行されたスコープは、要求されるスコープとは異なる場合があります。この場合、`scope`パラメーターが、応答JSONに含まれます。
* 特定のスコープを要求しない場合、この付与でのアプリケーションへの黙示的な信頼によって、オーディエンスに定義されたすべてのスコープが返されます。ルールで返されるスコープをカスタマイズできます。詳細については、[信頼性の高いアプリケーションからAPIを呼び出す](https://auth0.com/docs/ja-jp/get-started/authentication-and-authorization-flow/resource-owner-password-flow)をご覧ください。

詳しく学ぶ

* [ネイティブiOSアプリにAppleでのサインインを追加する](https://auth0.com/docs/ja-jp/authenticate/identity-providers/social-identity-providers/apple-native)
* [iOS Swift - Appleサインインのクイックスタート](https://auth0.com/docs/ja-jp/quickstart/native/ios-swift)

## Parameters

<ParamField body="auth0-forwarded-for" type="string">
  文字列値としてのエンドユーザーIP。サーバー側のシナリオで総当たり攻撃防御を有効にしたい場合は、これを設定します。このヘッダーの使用方法とタイミングについて詳しく学ぶには、[サーバー側からリソース所有者のパスワードを使用する](/docs/ja-jp/api/authentication/api-auth/tutorials/using-resource-owner-password-from-server-side)をご覧ください。
</ParamField>

<ParamField body="grant_type" type="string">
  使用するフローを示します。ネイティブソーシャルのトークン交換については、`urn:ietf:params:oauth:grant-type:token-exchange`を使用します。
</ParamField>

<ParamField body="subject_token" type="string">
  ユーザーを表す外部で発行されたIDアーティファクトです。
</ParamField>

<ParamField body="subject_token_type" type="string">
  `subject_token`の種類を示す識別子。
</ParamField>

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

<ParamField body="audience" type="string">
  アクセスしたいターゲットAPIの一意の識別子です。
</ParamField>

<ParamField body="scope" type="string">
  アプリケーションが要求する様々なスコープの文字列値。複数のスコープは、空白文字で区切ります。
</ParamField>

<ParamField body="user_profile" type="object">
  iOSにネイティブなやり取りに使用される任意の要素で、このためにプロファイルが更新されます。予期されているパラメーターの値は次の形式のJSONです：`{ name: { firstName: 'John', lastName: 'Smith' }}`。
</ParamField>

<ParamField body="name" type="object" />

<ParamField body="firstName" type="string" />

<ParamField body="lastName" type="string" />

## Response

| Status  | Description |
| ------- | ----------- |
| 200     | 成功レスポンス     |
| default | 予期しないエラー    |
