Passer au contenu principal
PUT
https://{tenantDomain}/api/v2
/
users
/
{id}
/
authentication-methods
C#
using Auth0.ManagementApi;
using System.Threading.Tasks;
using System.Collections.Generic;

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

        await client.Users.AuthenticationMethods.SetAsync(
            id: "id",
            request: new List<SetUserAuthenticationMethods>(){
                new SetUserAuthenticationMethods {
                    Type = AuthenticationTypeEnum.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"
)

func do() {
client := client.NewClient(
option.WithToken(
"<token>",
),
)
request := []*management.SetUserAuthenticationMethods{
&management.SetUserAuthenticationMethods{
Type: management.AuthenticationTypeEnumPhone,
},
}
client.Users.AuthenticationMethods.Set(
context.TODO(),
"id",
request,
)
}
package com.example.usage;

import com.auth0.client.mgmt.ManagementApi;
import com.auth0.client.mgmt.types.AuthenticationTypeEnum;
import com.auth0.client.mgmt.types.SetUserAuthenticationMethods;
import java.util.Arrays;

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

client.users().authenticationMethods().set(
"id",
Arrays.asList(
SetUserAuthenticationMethods
.builder()
.type(AuthenticationTypeEnum.PHONE)
.build()
)
);
}
}
<?php

namespace Example;

use Auth0\SDK\API\Management\Management;
use Auth0\SDK\API\Management\Types\SetUserAuthenticationMethods;
use Auth0\SDK\API\Management\Types\AuthenticationTypeEnum;

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

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

client.users.authentication_methods.set(
id="id",
request=[
SetUserAuthenticationMethods(
type="phone",
)
],
)
require "auth0"

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

client.users.authentication_methods.set(
id: "id",
request: [{
type: "phone"
}]
)
import { ManagementClient } from "auth0";

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

async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.users.authenticationMethods.set("id", [
{
type: "phone",
},
]);
}
main();
curl --request PUT \
--url https://{tenantDomain}/api/v2/users/{id}/authentication-methods \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
[
{
"name": "<string>",
"phone_number": "<string>",
"email": "<string>",
"totp_secret": "<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>",
    "created_at": "2023-11-07T05:31:56Z"
  }
]

Autorisations

Authorization
string
header
requis

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

Paramètres de chemin

id
string
requis

The ID of the user in question.

Corps

type
enum<string>
requis
Options disponibles:
phone,
email,
totp
preferred_authentication_method
enum<string>

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

Options disponibles:
voice,
sms
name
string

AA human-readable label to identify the authentication method.

Required string length: 1 - 20
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.

Minimum string length: 1
totp_secret
string

Applies to totp authentication methods only. The base32 encoded secret for TOTP generation.

Minimum string length: 1

Réponse

All authentication methods successfully updated.

type
enum<string>
requis
Options disponibles:
phone,
email,
totp,
webauthn-roaming
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

Options disponibles:
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.

created_at
string<date-time>

Authentication method creation date