メインコンテンツへスキップ
POST
https://{tenantDomain}/api/v2
/
users
/
{id}
/
authentication-methods
Go
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,
    )
}
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>"
]
}
'
import requests

url = "https://{tenantDomain}/api/v2/users/{id}/authentication-methods"

payload = {
"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>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenantDomain}/api/v2/users/{id}/authentication-methods",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
HttpResponse<String> response = Unirest.post("https://{tenantDomain}/api/v2/users/{id}/authentication-methods")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"totp_secret\": \"<string>\",\n \"phone_number\": \"<string>\",\n \"email\": \"<string>\",\n \"key_id\": \"<string>\",\n \"public_key\": \"<string>\",\n \"aaguid\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"relying_party_identifier\": \"<string>\",\n \"credential_backed_up\": true,\n \"identity_user_id\": \"<string>\",\n \"user_agent\": \"<string>\",\n \"user_handle\": \"<string>\",\n \"transports\": [\n \"<string>\"\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{tenantDomain}/api/v2/users/{id}/authentication-methods")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"totp_secret\": \"<string>\",\n \"phone_number\": \"<string>\",\n \"email\": \"<string>\",\n \"key_id\": \"<string>\",\n \"public_key\": \"<string>\",\n \"aaguid\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"relying_party_identifier\": \"<string>\",\n \"credential_backed_up\": true,\n \"identity_user_id\": \"<string>\",\n \"user_agent\": \"<string>\",\n \"user_handle\": \"<string>\",\n \"transports\": [\n \"<string>\"\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "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