メインコンテンツへスキップ
POST
https://{tenantDomain}/api/v2
/
users
/
{id}
/
authentication-methods
C#
using Auth0.ManagementApi;
using System.Threading.Tasks;
using Auth0.ManagementApi.Users;

public partial class Examples
{
    public async Task Example() {
        var client = new ManagementClient(
            token: "<token>"
        );

        await client.Users.AuthenticationMethods.CreateAsync(
            id: "id",
            request: new CreateUserAuthenticationMethodRequestContent {
                Type = CreatedUserAuthenticationMethodTypeEnum.Phone
            }
        );
    }

}
package example

import (
    context "context"

    management "github.com/auth0/go-auth0/management/management"
    client "github.com/auth0/go-auth0/management/management/client"
    option "github.com/auth0/go-auth0/management/management/option"
    users "github.com/auth0/go-auth0/management/management/users"
)

func do() {
    client := client.NewClient(
        option.WithToken(
            "<token>",
        ),
    )
    request := &users.CreateUserAuthenticationMethodRequestContent{
        Type: management.CreatedUserAuthenticationMethodTypeEnumPhone,
    }
    client.Users.AuthenticationMethods.Create(
        context.TODO(),
        "id",
        request,
    )
}
package com.example.usage;

import com.auth0.client.mgmt.ManagementApi;
import com.auth0.client.mgmt.resources.users.authenticationmethods.requests.CreateUserAuthenticationMethodRequestContent;
import com.auth0.client.mgmt.types.CreatedUserAuthenticationMethodTypeEnum;

public class Example {
    public static void main(String[] args) {
        ManagementApi client = ManagementApi
            .builder()
            .token("<token>")
            .build();

        client.users().authenticationMethods().create(
            "id",
            CreateUserAuthenticationMethodRequestContent
                .builder()
                .type(CreatedUserAuthenticationMethodTypeEnum.PHONE)
                .build()
        );
    }
}
<?php

namespace Example;

use Auth0\SDK\API\Management\Management;
use Auth0\SDK\API\Management\Users\AuthenticationMethods\Requests\CreateUserAuthenticationMethodRequestContent;
use Auth0\SDK\API\Management\Types\CreatedUserAuthenticationMethodTypeEnum;

$client = new Management(
    token: '<token>',
);
$client->users->authenticationMethods->create(
    'id',
    new CreateUserAuthenticationMethodRequestContent([
        'type' => CreatedUserAuthenticationMethodTypeEnum::Phone->value,
    ]),
);
from auth0.management import ManagementClient

client = ManagementClient(
    token="<token>",
)

client.users.authentication_methods.create(
    id="id",
    type="phone",
)
require "auth0"

client = Auth0::Management.new(token: "<token>")

client.users.authentication_methods.create(
  id: "id",
  type: "phone"
)
import { ManagementClient } from "auth0";

async function main() {
    const client = new ManagementClient({
        token: "<token>",
    });
    await client.users.authenticationMethods.create("id", {
        type: "phone",
    });
}
main();
import { ManagementClient } from "auth0";

async function main() {
    const client = new ManagementClient({
        token: "<token>",
    });
    await client.users.authenticationMethods.create("id", {
        type: "phone",
    });
}
main();
curl --request POST \
  --url https://{tenantDomain}/api/v2/users/{id}/authentication-methods \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "totp_secret": "<string>",
  "phone_number": "<string>",
  "email": "<string>",
  "key_id": "<string>",
  "public_key": "<string>",
  "aaguid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "relying_party_identifier": "<string>",
  "credential_backed_up": true,
  "identity_user_id": "<string>",
  "user_agent": "<string>",
  "user_handle": "<string>",
  "transports": [
    "<string>"
  ]
}
'
{
  "id": "<string>",
  "name": "<string>",
  "totp_secret": "<string>",
  "phone_number": "<string>",
  "email": "<string>",
  "authentication_methods": [
    {
      "id": "<string>"
    }
  ],
  "key_id": "<string>",
  "public_key": "<string>",
  "aaguid": "<string>",
  "relying_party_identifier": "<string>",
  "credential_backed_up": true,
  "identity_user_id": "<string>",
  "user_agent": "<string>",
  "user_handle": "<string>",
  "transports": [
    "<string>"
  ],
  "created_at": "2023-11-07T05:31:56Z"
}

承認

Authorization
string
header
必須

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

パスパラメータ

id
string
必須

The ID of the user to whom the new authentication method will be assigned.

ボディ

type
enum<string>
必須
利用可能なオプション:
phone,
email,
totp,
webauthn-roaming,
passkey
name
string

A human-readable label to identify the authentication method.

totp_secret
string

Base32 encoded secret for TOTP generation.

phone_number
string

Applies to phone authentication methods only. The destination phone number used to send verification codes via text and voice.

Required string length: 2 - 30
email
string

Applies to email authentication methods only. The email address used to send verification messages.

preferred_authentication_method
enum<string>

Applies to phone authentication methods only. The preferred communication method.

利用可能なオプション:
voice,
sms
key_id
string

Applies to webauthn/passkey authentication methods only. The id of the credential.

public_key
string

Applies to webauthn/passkey authentication methods only. The public key, which is encoded as base64.

aaguid
string<uuid>

Applies to passkeys only. Authenticator Attestation Globally Unique Identifier

relying_party_identifier
string<hostname>

Applies to webauthn authentication methods only. The relying party identifier.

credential_device_type
enum<string>

Applies to passkeys only. The kind of device the credential is stored on as defined by backup eligibility. "single_device" credentials cannot be backed up and synced to another device, "multi_device" credentials can be backed up if enabled by the end-user.

利用可能なオプション:
single_device,
multi_device
credential_backed_up
boolean

Applies to passkeys only. Whether the credential was backed up.

identity_user_id
string

Applies to passkeys only. The ID of the user identity linked with the authentication method.

user_agent
string

Applies to passkeys only. The user-agent of the browser used to create the passkey.

user_handle
string

Applies to passkeys only. The user handle of the user identity.

transports
string[]

Applies to passkeys only. The transports used by clients to communicate with the authenticator.

レスポンス

Authentication method created.

The successfully created authentication method.

type
enum<string>
必須
利用可能なオプション:
phone,
email,
totp,
webauthn-roaming,
passkey
id
string<authenticator-id>

The ID of the newly created authentication method (automatically generated by the application)

name
string

A human-readable label to identify the authentication method.

totp_secret
string

Base32 encoded secret for TOTP generation

phone_number
string

Applies to phone authentication methods only. The destination phone number used to send verification codes via text and voice.

Required string length: 2 - 30
email
string

Applies to email authentication methods only. The email address used to send verification messages.

authentication_methods
object[]
preferred_authentication_method
enum<string>

Preferred phone authentication method

利用可能なオプション:
voice,
sms
key_id
string

Applies to webauthn authenticators only. The id of the credential.

public_key
string

Applies to webauthn authenticators only. The public key.

aaguid
string

Applies to passkeys only. Authenticator Attestation Globally Unique Identifier.

relying_party_identifier
string

Applies to webauthn authenticators only. The relying party identifier.

credential_device_type
enum<string>

Applies to passkeys only. The kind of device the credential is stored on as defined by backup eligibility. "single_device" credentials cannot be backed up and synced to another device, "multi_device" credentials can be backed up if enabled by the end-user.

利用可能なオプション:
single_device,
multi_device
credential_backed_up
boolean

Applies to passkeys only. Whether the credential was backed up.

identity_user_id
string

Applies to passkeys only. The ID of the user identity linked with the authentication method.

user_agent
string

Applies to passkeys only. The user-agent of the browser used to create the passkey.

user_handle
string

Applies to passkeys only. The user handle of the user identity.

transports
string[]

Applies to passkeys only. The transports used by clients to communicate with the authenticator.

created_at
string<date-time>

Authentication method creation date