メインコンテンツへスキップ

始める前に

Auth0 Management APIには、認証方法の管理に使用できるエンドポイントがいくつかあります。 この方法では、機密アプリケーションを使った認証が用いられます。機密アプリケーションとパブリックアプリケーションの詳細については、「機密アプリケーションとパブリックアプリケーション」をお読みください。

すべての認証方法を取得する

認証方法リストの取得エンドポイントを使って、ユーザーが完全または部分的に登録した認証方法の全リストを取得します。 このエンドポイントには、read:authentication_methodsスコープが必要です。

以下の要求は特定のユーザーについて、すべての認証方法のリストを返します。
curl --request GET \
  --url https://%7ByourDomain%7D/api/v2/users/%7BuserId%7D/authentication-methods \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}'

応答

は、有効な各要求に対して、JSON形式の応答を返します。
[
  {
    "id": "totp|dev_XXXXXXXXXXXXXXXX",
    "type": "totp",
    "confirmed": true,
    "created_at": "2021-09-23T22:57:30.206Z",
    "last_auth_at": "2021-09-23T22:57:51.652Z"
  }
]

1つの認証方法を取得する

認証方法をIDで取得エンドポイントを使って、認証方法のIDで指定されたユーザーについて、1つの認証方法を取得します。 このエンドポイントには、read:authentication_methodsスコープが必要です。

以下の要求は、指定された認証方法のIDに基づいて、ユーザーの1つの認証方法を返します。
curl --request GET \
  --url https://%7ByourDomain%7D/api/v2/users/%7BuserId%7D/authentication-methods/%7BauthenticationMethodId%7D \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}'

応答

Management APIは、有効な各要求に対して、JSON形式の応答を返します。
{
    "id": "totp|dev_XXXXXXXXXXXXXXXX",
    "type": "totp",
    "confirmed": true,
    "created_at": "2021-09-23T22:57:30.206Z",
    "last_auth_at": "2021-09-23T22:57:51.652Z"
}

認証方法を作成する

指定ユーザーの認証方法作成エンドポイントを使って、SMSやメール、ワンタイムパスワード(OTP)、セキュリティキーを使用したWebAuthnといったユーザー認証方法を作成します。使用できるMFA認証要素の詳細については、「多要素認証の要素」をお読みください。 このエンドポイントには、create:authentication_methodsスコープが必要です。
このエンドポイントを使って作成された認証方法は、自動的に確認され、即座に使用可能になります。ユーザーの認証方法が正しく設定され、有効であることを確認してください。

SMS

SMSでユーザーにワンタイムパスワード(OTP)を送信します。ユーザーが認証を完了するには、このパスワードを入力する必要があります。

以下の要求はユーザーのSMS認証方法を作成します。
curl --request POST \
  --url https://%7ByourDomain%7D/api/v2/users/%7BuserId%7D/authentication-methods \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}' \
  --data '{ "type": "phone", "name": "SMS", "phone_number": "+00000000000" }'

応答

Management APIは、有効な各要求に対して、JSON形式の応答を返します。
{
    "type": "phone",
    "name": "SMS",
    "created_at": "2023-01-01T00:00:00.000Z",
    "phone_number": "user@example.com",
    "id": "phone|dev_XXXXXXXXXXXXXXXX"
}

メール

メールでユーザーにワンタイムパスワード(OTP)を送信します。ユーザーが認証を完了するには、このパスワードを入力する必要があります。メール要素は、ユーザーに使用できるその他の要素がない場合にのみサポートされます。

以下の要求はユーザーのメール認証方法を作成します。
curl --request POST \
  --url https://%7ByourDomain%7D/api/v2/users/%7BuserId%7D/authentication-methods \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}' \
  --data '{ "type": "email", "name": "Email Factor", "email": "user@example.com" }'

応答

Management APIは、有効な各要求に対して、JSON形式の応答を返します。
{
    "type": "email",
    "name": "Email Factor",
    "created_at": "2023-01-01T00:00:00.000Z",
    "email": "user@example.com",
    "id": "email|dev_XXXXXXXXXXXXXXXX"
}

ワンタイムパスワード(OTP)

ユーザーがGoogle Authenticatorなどの認証アプリケーションを個人用デバイスで使用して、定期的に変更されるOTPを生成できるようにします。ユーザーが認証を完了するには、このパスワードを入力する必要があります。

以下の要求はユーザーのOTP認証方法を作成します。
curl --request POST \
  --url https://%7ByourDomain%7D/api/v2/users/%7BuserId%7D/authentication-methods \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}' \
  --data '{ "type": "totp", "name": "OTP Application", "totp_secret": "{yourSecret}" }'

応答

Management APIは、有効な各要求に対して、JSON形式の応答を返します。
{
    "type": "totp",
    "name": "OTP Application",
    "created_at": "2023-01-01T00:00:00.000Z",
    "email": "user@example.com",
    "id": "totp|dev_XXXXXXXXXXXXXXXX"
}

セキュリティキーを使用したWebAuthn

ユーザーがFIDO準拠のセキュリティキー(YubikeyGoogle Titanなど)を使って、多要素認証を行えるようにします。

以下の要求はユーザーについて、セキュリティキーを使ったWebAuthn認証方法を作成します。
curl --request POST \
  --url https://%7ByourDomain%7D/api/v2/users/%7BuserId%7D/authentication-methods \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}' \
  --data '{ "type": "webauthn_roaming", "name": "WebAuthn with security keys", "public_key": "{yourPublicKey}", "key_id": "{yourKeyId}", "relying_party_identifier": "{yourDomain}" }'

応答

Management APIは、有効な各要求に対して、JSON形式の応答を返します。
{
    "type": "webauthn-roaming",
    "name": "WebAuthn with security keys",
    "relyingPartyIdentifier": "example-tenant.auth0.com",
    "keyId": "X9FrwMfmzj...",
    "publicKey": "bXktcHVibGljLWtle...",
    "created_at": "2023-03-09T17:33:47.545Z",
    "id": "webauthn-roaming|dev_XXXXXXXXXXXXXXXX"
}

すべての認証方法を置き換える

全品証方法を指定方法に更新エンドポイントを使って、既存のすべての認証方法を指定されたもので置き換えます。 このエンドポイントには、update:authentication_methodsスコープが必要です。

以下の要求はユーザーについて、既存のすべての認証方法を置き換えます。
curl --request PUT \
  --url https://%7ByourDomain%7D/api/v2/users/%7BuserId%7D/authentication-methods \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}' \
  --data '[{ "type": "phone", "preferred_authentication_method": "sms", "phone_number": "+00000000000", "name": "SMS" }]'

応答

Management APIは、有効な各要求に対して、JSON形式の応答を返します。
[
  {
    "id": "phone|dev_XXXXXXXXXXXXXXXX",
    "type": "phone",
    "name": "SMS",
    "phone_number": "+00000000000",
    "created_at": "2023-03-09T17:53:23.647Z",
    "preferred_authentication_method": "sms",
    "authentication_methods": [
      {
        "id": "sms|dev_XXXXXXXXXXXXXXXX",
        "type": "sms"
      }
    ]
  }
]

1つの認証方法を更新する

1認証方法の更新エンドポイントを使って、ユーザーの1つの認証方法を更新します。 このエンドポイントには、update:authentication_methodsスコープが必要です。

以下の要求は、特定の認証方法のIDに基づいて、ユーザーの1つの認証方法を更新します。
curl --request PATCH \
  --url https://%7ByourDomain%7D/api/v2/users/%7BuserId%7D/authentication-methods/%7BauthenticationMethodId%7D \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}' \
  --data '{ "name": "Mobile SMS" }'

応答

Management APIは、有効な各要求に対して、JSON形式の応答を返します。
{
    "type": "phone",
    "name": "Mobile SMS",
    "created_at": "2023-01-12T00:03:52.855Z",
    "last_auth_at": "2023-01-12T00:04:05.157Z",
    "phone_number": "+00000000000",
    "preferred_authentication_method": "sms",
    "id": "phone|dev_XXXXXXXXXXXXXXXX",
    "authentication_methods": [
        {
            "id": "phone|dev_XXXXXXXXXXXXXXXX",
            "type": "phone"
        }
    ]
}

すべての認証方法を削除する

指定ユーザーの全認証方法削除エンドポイントを使って、ユーザーのすべての認証方法を削除します。 このエンドポイントには、delete:authentication_methodsスコープが必要です。

以下の要求はユーザーのすべての認証方法を削除します。
curl --request DELETE \
  --url https://%7ByourDomain%7D/api/v2/users/%7BuserId%7D/authentication-methods \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}'

応答

Management APIは、有効な各要求に対して、ステータスコード204と空の本文を返します。

1つの認証方法を削除する

認証方法をIDで削除エンドポイントを使って、ユーザーの1つの認証方法を削除します。

以下の要求は、指定された認証方法のIDに基づいて、ユーザーの1つの認証方法を削除します。
curl --request DELETE \
  --url https://%7ByourDomain%7D/api/v2/users/%7BuserId%7D/authentication-methods/%7BauthenticationMethodId%7D \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}'

応答

Management APIは、有効な各要求に対して、ステータスコード204と空の本文を返します。

もっと詳しく

I