> ## 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 Token にカスタムクレームを追加します。詳しくは、[User profile claims and scope](https://auth0.com/docs/get-started/apis/scopes/openid-connect-scopes) を参照してください。
* このエンドポイントは、rate limits に関するデータを示す 3 つの HTTP レスポンスヘッダーを返します。
  * `X-RateLimit-Limit`: 1 分あたりに許可されるリクエスト数。
  * `X-RateLimit-Remaining`: 利用可能なリクエスト数。新しいリクエストがあるたびに、この数は 1 ずつ減ります。1 分経過するごとにリクエスト数が回復するため、この数はそのたびに 1 ずつ増えます。
  * `X-RateLimit-Reset`: rate limit (`X-RateLimit-Limit`) がリセットされるまでの残り時間。値は [UTC epoch seconds](https://en.wikipedia.org/wiki/Unix_time) で表されます。
* `Email` クレームは、ログイン時点のメールアドレスのスナップショットを返します。
* 標準クレーム (`email` を除く) は最新の値を返します (ただし、その値が外部 IdP から取得されたものである場合を除きます) 。
* カスタムクレームは常に、そのクレームの最新の値を返します。
* `email` またはカスタムクレームの最新の値にアクセスするには、新しいトークンを取得する必要があります。サイレント authentication ([`authorize` エンドポイント](https://auth0.com/docs/api/authentication#authorization-code-grant) の呼び出し時に `prompt` パラメーターを `none` に設定) を使用してログインできます。
* 外部 IdP によって変更された標準クレームの最新の値にアクセスするには (たとえば、ユーザーが Facebook でメールアドレスを変更した場合) 、新しいトークンを取得する必要があります。サイレント authentication は使用せず、外部 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 プルーフです。これは任意で、アプリケーションで Demonstrating Proof-of-Possession を使用している場合にのみ必要です。
</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">
    ユーザーが希望するユーザー名。
  </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時間) 。
  </ResponseField>
</ResponseSchema>

<div id="response-messages">
  ## 応答メッセージ
</div>

| ステータス | 説明                             |
| ----- | ------------------------------ |
| 200   | ユーザープロファイルの取得に成功しました。          |
| 401   | 未認証、またはアクセストークンが無効もしくは不足しています。 |
