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

# ユーザー情報を取得

> openid スコープが付与されている場合、Auth0 アクセストークンを使用してユーザープロフィールを返します。

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>

`GET /userinfo`

ログイン時に取得した Auth0 アクセストークンを指定すると、このエンドポイントはユーザープロフィールを返します。このエンドポイントは、アクセストークンに `openid` スコープが付与されている場合にのみ機能します。レスポンスに含まれるユーザープロフィール情報は、要求したスコープによって異なります。たとえば、スコープが `openid` のみの場合、`openid profile email` の場合より返される情報が少なくなることがあります。

<div id="remarks">
  ### 注記
</div>

* サンプルの auth0.js スクリプトでは、ライブラリのバージョン 8 を使用しています。auth0.js バージョン 7 を使用している場合は、この[リファレンスガイド](https://auth0.com/docs/libraries/auth0js/v7)を参照してください。
* auth0.js の `parseHash` メソッドでは、トークンが `HS256` ではなく `RS256` で署名されている必要があります。
* このエンドポイントから `user_metadata` やその他のカスタム情報を返すには、[Action](https://auth0.com/docs/secure/tokens/json-web-tokens/create-custom-claims#create-custom-claims) を使用して IDトークンにカスタムクレームを追加します。詳細については、[ユーザープロファイルのクレームとスコープ](https://auth0.com/docs/get-started/apis/scopes/openid-connect-scopes)を参照してください。
* このエンドポイントは、レート制限に関する情報を提供する 3 つの HTTP レスポンスヘッダーを返します。
  * `X-RateLimit-Limit`: 1 分あたりに許可されるリクエスト数。
  * `X-RateLimit-Remaining`: 利用可能なリクエスト数。リクエストを 1 回送信するたびに、この値は 1 減少します。1 分経過するごとにリクエスト数が 1 回分復元されるため、そのたびにこの値は 1 増加します。
  * `X-RateLimit-Reset`: レート制限 (`X-RateLimit-Limit`) がリセットされるまでの残り時間。値は [UTC エポック秒](https://en.wikipedia.org/wiki/Unix_time)です。
* `Email` クレームは、ログイン時点のメールアドレスの値を返します。
* 標準クレーム (`email` を除く) は最新の値を返します (ただし、その値が外部 IdP に由来する場合を除きます) 。
* カスタムクレームは常に最新の値を返します。
* `email` またはカスタムクレームの最新の値にアクセスするには、新しいトークンを取得する必要があります。サイレント認証を使用してログインできます ([`authorize` endpoint](https://auth0.com/docs/api/authentication#authorization-code-grant) の呼び出しで `prompt` パラメーターを `none` に設定します) 。
* 外部 IdP によって変更された標準クレームの最新の値にアクセスするには (たとえば、ユーザーが Facebook でメールアドレスを変更した場合) 、新しいトークンを取得する必要があります。サイレント認証は使用せず、外部 IdP を使って再度ログインしてください。

<div id="learn-more">
  ### 詳細情報
</div>

* [Auth0.js v8 リファレンス: authResult を抽出し、ユーザー情報を取得する](https://auth0.com/docs/libraries/auth0js#extract-the-authresult-and-get-user-info)
* [Auth0 API レート制限ポリシー](https://auth0.com/docs/troubleshoot/customer-support/operational-policies/rate-limit-policy)

<div id="headers">
  ## ヘッダー
</div>

<ParamField header="access_token" type="string" required />

<ParamField header="DPoP" type="string">
  リクエストの DPoP 証明です。省略可能で、アプリケーションで所有証明 (DPoP) を使用している場合にのみ必要です。
</ParamField>

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

<ResponseSchema>
  <ResponseField name="sub" type="string">
    ユーザーの一意の識別子。
  </ResponseField>

  <ResponseField name="name" type="string">
    ユーザーのフルネーム。
  </ResponseField>

  <ResponseField name="given_name" type="string">
    ユーザーの名。
  </ResponseField>

  <ResponseField name="family_name" type="string">
    ユーザーの姓。
  </ResponseField>

  <ResponseField name="middle_name" type="string">
    ユーザーのミドルネーム。
  </ResponseField>

  <ResponseField name="nickname" type="string">
    ユーザーのニックネーム。
  </ResponseField>

  <ResponseField name="preferred_username" type="string">
    ユーザーが優先して使用する username。
  </ResponseField>

  <ResponseField name="profile" type="string">
    ユーザーのプロフィールページのURL。
  </ResponseField>

  <ResponseField name="picture" type="string">
    ユーザーのプロフィール画像のURL。
  </ResponseField>

  <ResponseField name="website" type="string">
    ユーザーのWebサイトのURL。
  </ResponseField>

  <ResponseField name="email" type="string">
    ユーザーのメールアドレス。
  </ResponseField>

  <ResponseField name="email_verified" type="boolean">
    ユーザーのメールアドレスが確認済みかどうか。
  </ResponseField>

  <ResponseField name="gender" type="string">
    ユーザーの性別。
  </ResponseField>

  <ResponseField name="birthdate" type="string">
    ユーザーの生年月日。
  </ResponseField>

  <ResponseField name="zoneinfo" type="string">
    ユーザーのタイムゾーン。
  </ResponseField>

  <ResponseField name="locale" type="string">
    ユーザーのロケール。
  </ResponseField>

  <ResponseField name="phone_number" type="string">
    ユーザーの電話番号。
  </ResponseField>

  <ResponseField name="phone_number_verified" type="boolean">
    ユーザーの電話番号が確認済みかどうか。
  </ResponseField>

  <ResponseField name="address" type="object">
    ユーザーの住所。
  </ResponseField>

  <ResponseField name="updated_at" type="integer">
    Unix timeで表した、ユーザー情報の最終更新時刻。
  </ResponseField>
</ResponseSchema>

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

| ステータス | 説明                                |
| ----- | --------------------------------- |
| 200   | ユーザープロフィールを正常に取得しました。             |
| 401   | 認証されていません。アクセストークンが無効か、指定されていません。 |
