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

# IDで同意を取得する

> 認証済みユーザーの特定の同意を ID で取得します。



## OpenAPI

````yaml docs/ja-jp/oas/myaccount/myaccount-api-oas.json GET /consents/{consent_id}
openapi: 3.1.0
info:
  title: My Account
  version: '1.0'
  description: >-
    Auth0 My Account API は、ユーザーが自分のアカウント情報を管理するための専用のエンドポイント群を提供します。これらの API
    を使用すると、お客様はアプリケーション内でセルフサービス体験を構築したり、ユーザーアカウントに詳細情報を段階的に追加したりできます。


    My Account API は、現在ログイン中のユーザーのコンテキストで動作し、ユーザー向けアプリケーション内で直接使用できます。


    :::tip Auth0 ドメインとカスタムドメインの使い分け


    My Account API では、正規の Auth0
    ドメインまたはカスタムドメインを使用できますが、次の項目を含むプロセス全体で、必ず同じものを使用する必要があります。


    - アクセストークンを取得する

    - audience の値を設定する

    - My Account API エンドポイントを呼び出す


    詳しくは、[Custom Domains](https://auth0.com/docs/customize/custom-domains)
    をご覧ください。


    :::


    ## My Account API を有効化する


    Auth0 Dashboard でテナントの My Account API を有効化できます。


    1. Authentication > APIs に移動します。

    2. MyAccount API のバナーを見つけます。

    3. Activate を選択します。


    ![](https://images.ctfassets.net/cdy7uua7fh8z/DGkDQNIHcegN8vtQyEvF3/a2e98b06867701a66fa1f1b3df1c996b/My_Account_API_-_Activate.png)


    デフォルトでは、My Account API は次の application API access policies で作成されます。


    `require_client_grant` はユーザーフロー用


    `deny_all` はクライアント（machine-to-machine）フロー用


    アプリケーションがユーザーに代わって My Account API
    にアクセスするには、そのアプリケーションに対してクライアントグラントを明示的に作成する必要があります。これにより、そのアプリケーションがリクエストできるスコープの上限を定義できます。あるいは、ユーザーアクセスポリシーのフローを
    allow_all に変更することもできます。これにより、テナント内の任意のアプリケーションが My Account API に対して任意の scope
    をリクエストできるようになります。


    My Account API は機密性の高い情報や操作を公開するため、Auth0 ではユーザーアクセスポリシーのフローに allow_all
    を使用することを推奨していません。My Account API
    では最小権限の原則に従い、アプリケーションが本当に必要なものにのみアクセスできるようにして、潜在的なセキュリティリスクを最小限に抑える必要があります。


    アプリケーションに最終的に付与される権限は、application API access policy でアプリケーションに許可される
    scopes、エンドユーザーに割り当てられたロールベースのアクセス制御 (RBAC)
    の権限、およびユーザーの同意（該当する場合）の共通部分によって決まります。


    :::info サポートされているフロー


    My Account API へのクライアントアクセス用の application API policy
    は更新できません。つまり、クライアント認証情報フローを使用して My Account API にアクセスすることはできません。


    :::


    application API access policies と、それに関連付けられた client grants
    の管理方法について詳しくは、[Application Access to APIs: Client
    Grants](https://auth0.com/docs/get-started/applications/application-access-to-apis-client-grants)
    をご覧ください。


    ## アクセストークンを取得する


    My Account API 用のアクセストークンは、自分の API 用のアクセストークンを取得する場合と同じ方法で取得できます。


    :::info &nbsp

    My Account API に機密性の高い操作（認証方法の登録など）を許可する場合は、[多要素認証
    (MFA)](https://auth0.com/docs/secure/multi-factor-authentication)
    によって追加のセキュリティポリシーを適用するために、[step-up
    authentication](https://auth0.com/docs/secure/multi-factor-authentication/step-up-authentication)
    を使用することを強く推奨します。

    :::


    Universal Login を使用している場合は、次の記事を参照してください。


    - [Call Your API Using the Authorization Code
    Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow/call-your-api-using-the-authorization-code-flow)

    - [Call Your API Using the Authorization Code Flow with
    PKCE](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow-with-pkce/call-your-api-using-the-authorization-code-flow-with-pkce)


    組み込みログインを使用している場合は、次の記事を参照してください。


    - [Call Your API Using Resource Owner Password
    Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/resource-owner-password-flow/call-your-api-using-resource-owner-password-flow)

    - [Login Flow with Native Passkeys
    API](https://auth0.com/docs/native-passkeys-api#login-flow)


    ## 例


    ### Universal Login での認可コードフロー


    **ステップ 1: 認可コードをリクエストする**


    ```

    curl --request GET \
      --url 'https://{yourDomain}/authorize?response_type=code&client_id={yourClientId}&redirect_uri=%7ByourRedirectUri%7D&scope=create%3Ame%3Aauthentication_methods&offline_access=&audience=https%3A%2F%2F{yourDomain}%2Fme%2F'
    ```


    **ステップ 2: code をアクセストークンと交換する**


    ```

    curl --request POST \
      --url 'https://{yourDomain}/oauth/token' \
      --header 'content-type: application/json' \
      --data '{"grant_type": "authorization_code","client_id": "{yourClientId}","client_secret": "{yourClientSecret}","code": "{yourAuthorizationCode}","redirect_uri": "{yourRedirectUri}","audience": "{yourAudience}","scope": "create:me:authentication_methods","offline_access": ""}'
    ```


    ### ネイティブ パスキーを使った埋め込み型ログイン


    **ステップ 1: ログインチャレンジをリクエストする**


    ```

    curl --request POST \
      --url 'https://{yourDomain}/passkey/challenge' \
      --header 'content-type: application/json' \
      --data '{"client_id": "{yourClientId}"}'
    ```


    **ステップ 2: 既存のユーザーを認証する**


    ```

    curl --request POST \
      --url 'https://{yourDomain}/oauth/token' \
      --header 'content-type: application/json' \
      --data '{  "grant_type": "urn:okta:params:oauth:grant-type:webauthn",  "client_id": "{yourClientId}",  "scope": "create:me:authentication_methods offline_access",  "audience": "https://{yourDomain}/me/",  "auth_session": "{sessionIdFromTheFirstRequest}",  "authn_response": "{authenticatorResponse}"}'
    ```
servers:
  - url: https://{host}/me/v1
    variables:
      host:
        default: auth0.auth0.com
        description: カスタムまたは標準のホスト名
security: []
tags:
  - name: factors
    description: 認証要素
    x-displayName: Factors
  - name: connected-accounts
    description: Connected Accounts
    x-displayName: Connected Accounts
  - name: authentication-methods
    description: 認証方法
    x-displayName: Authentication Methods
  - name: consents
    description: 同意
    x-displayName: Consents
  - name: organizations
    description: Organizations
    x-displayName: Organizations
  - name: profile
    description: プロフィール
    x-displayName: Profile
paths:
  /consents/{consent_id}:
    get:
      tags:
        - consents
      summary: IDで同意を取得する
      description: 認証済みユーザーの特定の同意を ID で取得します。
      operationId: getConsent
      parameters:
        - $ref: '#/components/parameters/PathConsentId'
        - $ref: '#/components/parameters/HeaderCorrelationId'
        - $ref: '#/components/parameters/HeaderTraceparent'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetConsentResponseContent'
          description: 同意を正常に取得しました
          headers:
            x-ratelimit-limit:
              $ref: '#/components/headers/XRateLimitLimitHeader'
            x-ratelimit-reset:
              $ref: '#/components/headers/XRateLimitResetHeader'
            x-ratelimit-remaining:
              $ref: '#/components/headers/XRateLimitRemainingHeader'
            x-correlation-id:
              $ref: '#/components/headers/CorrelationIdHeader'
            traceparent:
              $ref: '#/components/headers/TraceparentHeader'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      security:
        - Bearer-DPoP:
            - read:me:consents
      x-codeSamples: []
components:
  parameters:
    PathConsentId:
      in: path
      name: consent_id
      required: true
      schema:
        type: string
      description: 取得する Consent の ID
    HeaderCorrelationId:
      in: header
      name: x-correlation-id
      required: false
      schema:
        type: string
      x-sdk-ignore: true
      description: >-
        Auth0システム全体でリクエストを関連付けるために使用する、クライアントが指定する1回の操作の一意識別子です。この値はテナントログの`references.correlation_id`に表示され、レスポンスの`x-correlation-id`ヘッダーで返されます。無効または大きすぎる値は通知なく破棄され、生成されたUUID
        v4に置き換えられます。個人を特定できる情報（PII）は含めないでください。
    HeaderTraceparent:
      in: header
      name: traceparent
      required: false
      schema:
        type: string
      x-sdk-ignore: true
      description: >-
        分散トレース全体でリクエストを関連付けるために使用する[W3C Trace
        Context](https://www.w3.org/TR/trace-context/)ヘッダーです。指定された場合は受信トレースが継続され、新しい子スパンがレスポンスの`traceparent`ヘッダーで返されます。トレースIDはテナントログの`references.trace_id`にも表示されます。形式が不正な値は無視されます。
  schemas:
    GetConsentResponseContent:
      allOf:
        - $ref: '#/components/schemas/Consent'
    Consent:
      type: object
      description: 特定のクライアントとスコープに対するユーザーの認可を表す consent record。
      properties:
        id:
          type: string
          description: consent の一意の識別子。
          example: cns_abc123def456
        client_id:
          type: string
          description: consent の付与先である client ID。
        requested_details:
          $ref: '#/components/schemas/ConsentDetails'
        created_at:
          type: string
          format: date-time
          description: consent が作成された日時。
        expires_at:
          type: string
          format: date-time
          description: consent の有効期限日時。
        challenge:
          type: string
          description: プッシュ通知によって開始された、この同意に関連付けられた MFA チャレンジ。プッシュ通知が関連付けられている場合にのみ含まれます。
      required:
        - id
        - client_id
        - requested_details
        - created_at
        - expires_at
      additionalProperties: false
    ErrorResponse:
      properties:
        type:
          type: string
        status:
          type: number
        title:
          type: string
        detail:
          type: string
        validation_errors:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      required:
        - type
        - status
        - title
        - detail
      type: object
      additionalProperties: false
    ConsentDetails:
      type: object
      description: 同意リクエストの詳細
      properties:
        binding_message:
          type: string
          description: >-
            人が理解しやすい識別子またはメッセージ。エンドユーザー向けの視覚的な手がかりとして consumption device
            と認証デバイスの両方に表示され、transaction 内で両者を結び付けるためのものです。
        audience:
          type: string
          description: consent が付与された対象の audience（API 識別子）。
        scope:
          type: array
          items:
            type: string
          description: この consent に対して要求されたスコープ。
        authorization_details:
          type: array
          items:
            $ref: '#/components/schemas/AuthorizationDetailsItem'
          description: この同意に関連付けられた完全な認可詳細オブジェクト。
      additionalProperties: false
    ValidationError:
      type: object
      properties:
        detail:
          type: string
        field:
          type: string
        pointer:
          type: string
        source:
          type: string
      required:
        - detail
      additionalProperties: false
    AuthorizationDetailsItem:
      type: object
      description: >-
        RFC
        9396で定義される単一の認可詳細オブジェクト。存在が保証されるのは`type`のみで、他のフィールドはすべて認可詳細のタイプに固有であるため、このオブジェクトは意図的にオープンになっています。
      properties:
        type:
          type: string
          description: RFC 9396で定義される認可詳細タイプの識別子。
      additionalProperties: true
  headers:
    XRateLimitLimitHeader:
      required: true
      description: 制限ウィンドウ内で許可されるリクエストの最大数
      schema:
        type: number
    XRateLimitResetHeader:
      required: true
      description: bucket が補充される予定時刻（UNIXタイムスタンプ、秒単位）
      schema:
        type: number
    XRateLimitRemainingHeader:
      required: true
      description: リクエストが拒否されるまで、現在のウィンドウ内で残っているリクエスト数
      schema:
        type: number
    CorrelationIdHeader:
      required: false
      description: リクエストで指定された検証済みの`x-correlation-id`、または指定されなかった場合は生成されたUUID v4を返します。
      schema:
        type: string
    TraceparentHeader:
      required: false
      description: >-
        新しい子スパンIDとともに受信トレースIDを返す[W3C Trace
        Context](https://www.w3.org/TR/trace-context/)ヘッダー。
      schema:
        type: string
    RetryAfterHeader:
      required: true
      description: クライアントが新しいリクエストを行う前に待機すべき秒数
      schema:
        type: number
    XAuth0ErrorKindHeader:
      description: レート制限の超過がグローバル（tenant 単位）制限であることを示す指標。
      schema:
        type: string
        const: global-rate-limit
  responses:
    Unauthorized:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: 認証されていません。
      headers:
        x-correlation-id:
          $ref: '#/components/headers/CorrelationIdHeader'
        traceparent:
          $ref: '#/components/headers/TraceparentHeader'
    Forbidden:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: アクセスが禁止されています。
      headers:
        x-correlation-id:
          $ref: '#/components/headers/CorrelationIdHeader'
        traceparent:
          $ref: '#/components/headers/TraceparentHeader'
    NotFound:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: 見つかりません。
      headers:
        x-correlation-id:
          $ref: '#/components/headers/CorrelationIdHeader'
        traceparent:
          $ref: '#/components/headers/TraceparentHeader'
    TooManyRequests:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: リクエストが多すぎます。
      headers:
        retry-after:
          $ref: '#/components/headers/RetryAfterHeader'
        x-ratelimit-limit:
          $ref: '#/components/headers/XRateLimitLimitHeader'
        x-ratelimit-reset:
          $ref: '#/components/headers/XRateLimitResetHeader'
        x-ratelimit-remaining:
          $ref: '#/components/headers/XRateLimitRemainingHeader'
        x-auth0-error-kind:
          $ref: '#/components/headers/XAuth0ErrorKindHeader'
        x-correlation-id:
          $ref: '#/components/headers/CorrelationIdHeader'
        traceparent:
          $ref: '#/components/headers/TraceparentHeader'
  securitySchemes:
    Bearer-DPoP:
      type: http
      scheme: bearer
      description: Bearer トークンと DPoP トークンは、API の設定に応じてサポートされます

````