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

# リカバリーコードで認証する

> ユーザーが登録済みデバイスを利用できない場合に、リカバリーコードを使用してMFA認証を行います。

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`

リカバリーコードを使用して多要素認証 (MFA) を検証します。Guardian などの一部の多要素認証 (MFA) プロバイダーでは、リカバリーコードを使ってログインできます。ユーザーが登録済みデバイスを利用できない場合や、接続の問題によりチャレンジを受信できない、または承認できない場合は、この方法で認証します。

リカバリーコードを使用して MFA を検証するには、アプリでユーザーにリカバリーコードの入力を求めたうえで、`grant_type=http://auth0.com/oauth/grant-type/mfa-recovery-code` を指定して `/oauth/token` にリクエストを送信する必要があります。入力されたリカバリーコードと、`mfa_required` エラーに含まれる `mfa_token` を含めてください。リカバリーコードが受け付けられると、レスポンスは `password` または `http://auth0.com/oauth/grant-type/password-realm` の grant type の場合と同じになります。また、`recovery_code` フィールドが含まれることもあり、その場合、アプリケーションは今後使用できるようエンドユーザーに表示し、安全に保管してもらう必要があります。

<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>
  使用するフローを指定します。リカバリーコードの場合は `http://auth0.com/oauth/grant-type/mfa-recovery-code` を使用します。

  指定可能な値: `http://auth0.com/oauth/grant-type/mfa-recovery-code`
</ParamField>

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

<ParamField body="client_assertion" type="string">
  アプリケーションの認証情報で署名されたアサーションを含む JWT。
</ParamField>

<ParamField body="client_assertion_type" type="string">
  値は `urn:ietf:params:oauth:client-assertion-type:jwt-bearer` です。

  指定可能な値: `urn:ietf:params:oauth:client-assertion-type:jwt-bearer`
</ParamField>

<ParamField body="client_secret" type="string">
  アプリケーションの Client Secret。
</ParamField>

<ParamField body="mfa_token" type="string" required>
  `mfa_required` エラーで受け取った `mfa_token`。
</ParamField>

<ParamField body="recovery_code" type="string" required>
  エンドユーザーが提供したリカバリーコード。
</ParamField>

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

<ResponseSchema>
  <ResponseField name="access_token" type="string">
    検証が成功した場合に返されるアクセストークン。
  </ResponseField>

  <ResponseField name="token_type" type="string">
    発行されたトークンの種類。
  </ResponseField>

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

  <ResponseField name="recovery_code" type="string">
    今後の使用に備えて安全に保管するための新しいリカバリーコード。
  </ResponseField>
</ResponseSchema>

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

| Status | Description                                  |
| ------ | -------------------------------------------- |
| 200    | リカバリーコードの検証に成功した場合のレスポンス。                    |
| 400    | パラメータが不足しているか無効なため、不正なリクエストです。               |
| 401    | 未認証です。`mfa_token` または `recovery_code` が無効です。 |
