> ## Documentation Index
> Fetch the complete documentation index at: https://docs-dev-docs-event-stream-action-templates.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ネイティブパスキーAPI

> ネイティブパスキー用のAuth0 Authentication API仕様

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  ネイティブパスキーは、現在、限定早期アクセスでご利用いただけます。Auth0のリリースについては、「[製品のリリース段階](/docs/ja-jp/troubleshoot/product-lifecycle/product-release-stages)」を参照してください。
</Callout>

ネイティブパスキーは、従来の認証形式（ユーザー名/パスワードなど）に代わるフィッシング耐性のある代替手段であり、より簡単かつ安全なユーザーエクスペリエンスを提供します。実装の詳細については、「[モバイルアプリケーション向けのネイティブパスキー](/docs/ja-jp/native-passkeys-for-mobile-applications)」を確認してください。

ネイティブパスキーは、Auth0とネイティブiOSまたはAndroid APIの組み合わせを使用して、チャレンジフローをモバイルアプリケーションに直接埋め込みます。以下に表示されたエンドポイントはAuth0 Authentication APIのサブセットとして、限定早期アクセスで現在利用することができます。このAPIの使用については、「[Authentication APIについて](https://auth0.com/docs/api/authentication#introduction)」を確認してください。

## サインアップフロー

### サインアップチャレンジを要求する

`POST /passkey/register`

新規ユーザーのパスキーサインアップフローを開始します。応答時に、Auth0は[PublicKeyCredentialCreationOptions](https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialcreationoptions)とセッションIDを返します。

#### 要求パラメーター

| パラメーター         | 説明                                                                                                                                                                                                                                                                                                                                                                                                             |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `client_id`    | **必須**。アプリケーションの`client_id`です。                                                                                                                                                                                                                                                                                                                                                                                 |
| `realm`        | **任意**。このユーザーに関連付ける接続の名前です。<br /><br />接続が指定されていない場合は、テナントのデフォルトのディレクトリが使用されます。                                                                                                                                                                                                                                                                                                                                |
| `user_profile` | **必須**。ユーザーのID情報を含むオブジェクトです。デフォルトでは、有効な`email`と任意の表示`name`が含まれます。<br /><br />データベース接続に[柔軟な識別子](/docs/ja-jp/authenticate/database-connections/activate-and-configure-attributes-for-flexible-identifiers)を有効にした場合は、識別子として`email`、`phone_number`、`username`を組み合わせて使うことができます。これらのオプションは必須または任意にできますが、柔軟な識別子の構成に一致する必要があります。<br /><br />渡された識別子（\`emailなど）がディレクトリに既に存在する場合には、代わりに、ユーザーにログインフローの完了を求めるメッセージが表示されます。 |

#### コード例

##### 要求

```json lines theme={null}
POST /passkey/register
Content-Type: application/json

{
  "client_id": "<CLIENT_ID>",
  "realm": "<OPTIONAL_CONNECTION>",
  "user_profile": {
	  "email": "<VALID_EMAIL_ADDRESS>",
	  "name": "<OPTIONAL_USER_DISPLAY_NAME>",
  }
}
```

##### 応答

```json lines theme={null}
HTTP/1.1 200 OK
Content-Type: application/json

{
  "authn_params_public_key": {
    "challenge": "<GENERATED_CHALLENGE_FOR_THIS_SESSION>",
    "timeout": <MILLISECONDS>,
    "rp": {
      "id": "<THE_CUSTOM_DOMAIN>",
      "name": "<THE_CUSTOM_DOMAIN>"
    },
    "pubKeyCredParams": [
      { type: 'public-key', alg: -8 },
      { type: 'public-key', alg: -7 },
      { type: 'public-key', alg: -257 }
    ],
    "authenticatorSelection": {
      "residentKey": "required",
      "userVerification": "preferred"
    },
    "user": {
      "id": "<GENERATED_ID>",
      "name": "<USER-ENTERED_IDENTIFIER>",
      "displayName": "<USER-ENTERED_DISPLAY_NAME_OR_IDENTIFIER_IF_MISSING>"
    }
  },
  "auth_session": "<SESSION_ID>"
}
```

#### 備考

* チャレンジ要求を完了したら、アプリケーションはネイティブの[Android](https://developer.android.com/identity/sign-in/credential-manager#create-passkey)または[iOS](https://developer.apple.com/documentation/authenticationservices/supporting-passkeys#Register-a-new-account-on-a-service) APIを使用して、ユーザー登録プロセスを続行することができます。
* その後、ネイティブAPIから取得した情報を使用して[新規ユーザーを認証](#authenticate-new-user)し、フローを完了する必要があります。

### 新規ユーザーを認証する

POST /<Tooltip data-tooltip-id="react-containers-DefinitionTooltip-0" href="/docs/ja-jp/glossary?term=oath2" tip="OAuth 2.0: 認可プロトコルとワークフローを定義する認可フレームワーク。" cta="用語集の表示">oauth</Tooltip>/token

トークンエンドポイントを使用して、指定された資格情報でユーザーを認証し、アカウントを作成して要求されたトークンを返します。

`authn_response`パラメーターは、[Web Authentication APIの仕様](https://www.w3.org/TR/webauthn-3/)に基づいています。ネイティブパスキーフローでは、このエンドポイントに渡された情報は、モバイルアプリケーションのネイティブAPIを介して取得することができます。

| パラメーター                                   | 説明                                                                                                                                                                                                                                                                                                                                       |
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `grant_type`                             | **必須**。次の値を含みます：`urn:okta:params:oauth:grant-type:webauthn`                                                                                                                                                                                                                                                                              |
| `scope`                                  | **任意**。`openid`を使用してIDトークンを取得するか、`openid profile email`を使用してIDトークンにユーザープロファイル情報を含めます。                                                                                                                                                                                                                                                    |
| `audience`                               | **任意**。アクセストークンを取得したいAPIのAPI識別子です。                                                                                                                                                                                                                                                                                                       |
| `auth_session`                           | **必須**。最初のパスキーチャレンジ要求中に返されるセッションIDです。                                                                                                                                                                                                                                                                                                    |
| `authn_response`                         | **必須**。以下の項目を含むオブジェクトです。<ul><li>`id`</li><li>`rawId`</li><li>`type`</li><li>`authenticatorAttachment`</li><li>`response`</li></ul>                                                                                                                                                                                                       |
| `authn_response.id`                      | **必須**。Base64URLの資格情報IDです。                                                                                                                                                                                                                                                                                                               |
| `authn_response.rawId`                   | **必須**。Base64URLの資格情報IDです。                                                                                                                                                                                                                                                                                                               |
| `authn_response.type`                    | **必須**。次の値を含みます：`public-key`                                                                                                                                                                                                                                                                                                             |
| `authn_response.authenticatorAttachment` | **必須**。次の値を含みます：<ul><li>`platform`</li><li>`cross-platform`</li></ul>                                                                                                                                                                                                                                                                    |
| `authn_response.response`                | **必須**。以下の項目を含むオブジェクトです。<ul><li>`clientDataJSON`：[AuthenticatorResponse](https://www.w3.org/TR/webauthn-3/#authenticatorresponse)から継承されたクライアントデータのJSON互換のシリアル化を含みます。</li><li>`attestationObject`：[AuthenticatorResponse](https://www.w3.org/TR/webauthn-3/#authenticatorresponse)から継承されたAuthenticatorデータとアテステーションステートメントを含みます。</li></ul> |

* [Androidでの登録に関するドキュメント](https://developer.android.com/identity/sign-in/credential-manager#create-passkey)
* [iOSでの登録に関するドキュメント](https://developer.apple.com/documentation/authenticationservices/supporting-passkeys#Register-a-new-account-on-a-service)

#### 要求パラメーター

```json lines theme={null}
POST /oauth/token
Content-Type: application/json

{
  "grant_type": "urn:okta:params:oauth:grant-type:webauthn",
  "client_id": "<CLIENT_ID>",
  "realm": "<OPTIONAL_CONNECTION>",
  "scope": "<OPTIONAL_REQUESTED_SCOPE>",
  "audience": "<OPTIONAL_REQUESTED_AUDIENCE>"
  "auth_session": "<SESSION_ID_FROM_THE_FIRST_REQUEST>",
  "authn_response": {
    "id": "<BASE64URL_ID>",
    "rawId": "<BASE64URL_RAWID>",
    "type": "public-key",
    "authenticatorAttachment": "platform|cross-platform",
    "response": {
      "clientDataJSON": "<BASE64URL_CLIENT_DATA_JSON>",
      "attestationObject": "<BASE64URL_ATTESTATION_OBJECT>",
      <OTHER_PROPERTIES>
    }  
}
```

#### コード例

##### 要求

```json lines theme={null}
HTTP/1.1 200 OK
Content-Type: application/json

{
  "access_token": "<BASE64_TOKEN>",
  "refresh_token": "<BASE64_TOKEN>",
  "id_token": "<BASE64_TOKEN>",
  "token_type": "Bearer",
  "expires_in": <SECONDS>
}
```

##### 応答

`POST /passkey/challenge`

## ログインフロー

### ログインチャレンジを要求する

初回のサインアップ時にパスキーをアカウントに保存した既存のユーザーについて、パスキーログインフローを開始します。

応答時に、Auth0は[PublicKeyCredentialRequestOptions](https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialrequestoptions)とセッションIDを返します。

| パラメーター      | 説明                                                                            |
| ----------- | ----------------------------------------------------------------------------- |
| `client_id` | **必須**。アプリケーションの`client_id`です。                                                |
| `realm`     | **任意**。ユーザーに関連付ける接続の名前です。<br /><br />接続が指定されていない場合は、テナントのデフォルトのディレクトリが使用されます。 |

#### 要求パラメーター

```json lines theme={null}
POST /passkey/challenge
Content-Type: application/json

{
  "client_id": "<CLIENT_ID>",
  "realm": "<OPTIONAL_CONNECTION>"
}
```

#### コード例

##### 要求

```json lines theme={null}
HTTP/1.1 200 OK
Content-Type: application/json

{
  "authn_params_public_key": {
    "challenge": "<GENERATED_CHALLENGE_FOR_THIS_SESSION>",
    "timeout": <AUTH_TIMEOUT_IN_MILLISECONDS>,
    "rpId": "<CUSTOM_DOMAIN>",
    "userVerification": "preferred"
  },
  "auth_session": "<SESSION_ID>"
}
```

##### 応答

POST /oauth/token

#### 備考

* チャレンジ要求を完了したら、アプリケーションはネイティブの[Android](https://developer.android.com/identity/sign-in/credential-manager#sign-in)または[iOS](https://developer.apple.com/documentation/authenticationservices/supporting-passkeys#Connect-to-a-service-with-an-existing-account) APIを使用して、ログインプロセスを続行することができます。
* その後、ネイティブAPIから取得した情報を使用して[既存のユーザーを認証し](#authenticate-existing-user)、フローを完了する必要があります。

### 既存のユーザーを認証する

トークンエンドポイントを使用して、指定された資格情報でユーザーを認証し、アカウントを作成して要求されたトークンを返します。

`authn_response`パラメーターは、[Web Authentication APIの仕様](https://www.w3.org/TR/webauthn-3/)に基づいています。ネイティブパスキーフローでは、このエンドポイントに渡された情報は、モバイルアプリケーションのネイティブAPIを介して取得することができます。

| パラメーター                                   | 説明                                                                                                                                                                                                                                                                                                                                       |
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `grant_type`                             | **必須**。次の値を含みます：`urn:okta:params:oauth:grant-type:webauthn`                                                                                                                                                                                                                                                                              |
| `scope`                                  | **任意**。`openid`を使用してIDトークンを取得するか、`openid profile email`を使用してIDトークンにユーザープロファイル情報を含めます。                                                                                                                                                                                                                                                    |
| `audience`                               | **任意**。アクセストークンを取得したいAPIのAPI識別子です。                                                                                                                                                                                                                                                                                                       |
| `auth_session`                           | **必須**。最初のパスキーチャレンジ要求中に返されるセッションIDです。                                                                                                                                                                                                                                                                                                    |
| `authn_response`                         | **必須**。以下の項目を含むオブジェクトです。<ul><li>`id`</li><li>`rawId`</li><li>`type`</li><li>`authenticatorAttachment`</li><li>`response`</li></ul>                                                                                                                                                                                                       |
| `authn_response.id`                      | **必須**。Base64URLの資格情報IDです。                                                                                                                                                                                                                                                                                                               |
| `authn_response.rawId`                   | **必須**。Base64URLの資格情報IDです。                                                                                                                                                                                                                                                                                                               |
| `authn_response.type`                    | **必須**。次の値を含みます：`public-key`                                                                                                                                                                                                                                                                                                             |
| `authn_response.authenticatorAttachment` | **必須**。次の値を含みます：<ul><li>`platform`</li><li>`cross-platform`</li></ul>                                                                                                                                                                                                                                                                    |
| `authn_response.response`                | **必須**。以下の項目を含むオブジェクトです。<ul><li>`clientDataJSON`：[AuthenticatorResponse](https://www.w3.org/TR/webauthn-3/#authenticatorresponse)から継承されたクライアントデータのJSON互換のシリアル化を含みます。</li><li>`attestationObject`：[AuthenticatorResponse](https://www.w3.org/TR/webauthn-3/#authenticatorresponse)から継承されたAuthenticatorデータとアテステーションステートメントを含みます。</li></ul> |

* [Androidでのログインに関するドキュメント](https://developer.android.com/identity/sign-in/credential-manager#sign-in)
* [iOSでのログインに関するドキュメント](https://developer.apple.com/documentation/authenticationservices/supporting-passkeys#Connect-to-a-service-with-an-existing-account)

#### 要求パラメーター

```json lines theme={null}
POST /oauth/token
Content-Type: application/json

{
  "grant_type": "urn:okta:params:oauth:grant-type:webauthn",
  "client_id": "<CLIENT_ID>",
  "realm": "<OPTIONAL_CONNECTION>",
  "scope": "<OPTIONAL_REQUESTED_SCOPE>",
  "audience": "<OPTIONAL_REQUESTED_AUDIENCE>"
  "auth_session": "<SESSION_ID_FROM_THE_FIRST_REQUEST>",
  "authn_response": {
    "id": "<BASE64URL_ID>",
    "rawId": "<BASE64URL_RAWID>",
    "type": "public-key",
    "authenticatorAttachment": "platform|cross-platform",
    "response": {
      "authenticatorData": "<BASE64URL_AUTHENTICATORDATA>",
      "clientDataJSON": "<BASE64URL_CLIENTDATAJSON>",
      "signature": "<BASE64URL_SIGNATURE>",
      "userHandle": "<BASE64URL_USERHANDLE>"
    },
    "clientExtensionResults": <OPTIONAL_OBJECT>
}
```

#### コード例

##### 要求

```json lines theme={null}
HTTP/1.1 200 OK
Content-Type: application/json

{
  "access_token": "<BASE64_TOKEN>",
  "refresh_token": "<BASE64_TOKEN>",
  "id_token": "<BASE64_TOKEN>",
  "token_type": "Bearer",
  "expires_in": <SECONDS>
}
```

##### 応答

```json lines theme={null}
HTTP/1.1 200 OK
Content-Type: application/json

{
  "access_token": "<BASE64_TOKEN>",
  "refresh_token": "<BASE64_TOKEN>",
  "id_token": "<BASE64_TOKEN>",
  "token_type": "Bearer",
  "expires_in": <SECONDS>
}
```
