Passer au contenu principal
POST
https://{tenantDomain}/api/v2
/
users
/
{id}
/
identities
Go
package example

import (
    context "context"

    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.LinkUserIdentityRequestContent{}
    client.Users.Identities.Link(
        context.TODO(),
        "id",
        request,
    )
}
import { ManagementClient } from "auth0";

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

async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.users.identities.link("id", {});
}
main();
curl --request POST \
--url https://{tenantDomain}/api/v2/users/{id}/identities \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"connection_id": "<string>",
"user_id": "abc",
"link_with": "{SECONDARY_ACCOUNT_JWT}"
}
'
import requests

url = "https://{tenantDomain}/api/v2/users/{id}/identities"

payload = {
"connection_id": "<string>",
"user_id": "abc",
"link_with": "{SECONDARY_ACCOUNT_JWT}"
}
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}/identities",
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([
'connection_id' => '<string>',
'user_id' => 'abc',
'link_with' => '{SECONDARY_ACCOUNT_JWT}'
]),
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}/identities")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"connection_id\": \"<string>\",\n \"user_id\": \"abc\",\n \"link_with\": \"{SECONDARY_ACCOUNT_JWT}\"\n}")
.asString();
require 'uri'
require 'net/http'

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

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 \"connection_id\": \"<string>\",\n \"user_id\": \"abc\",\n \"link_with\": \"{SECONDARY_ACCOUNT_JWT}\"\n}"

response = http.request(request)
puts response.read_body
[
  {
    "connection": "twitter",
    "user_id": "abc",
    "provider": "twitter",
    "profileData": {
      "email": "<string>",
      "email_verified": true,
      "name": "<string>",
      "username": "johndoe",
      "given_name": "<string>",
      "phone_number": "<string>",
      "phone_verified": true,
      "family_name": "<string>"
    },
    "isSocial": true,
    "access_token": "<string>",
    "access_token_secret": "<string>",
    "refresh_token": "<string>"
  }
]

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

ID of the primary user account to link a second user account to.

Corps

provider
enum<string>

Identity provider of the secondary user account being linked.

Options disponibles:
ad,
adfs,
amazon,
apple,
dropbox,
bitbucket,
auth0-oidc,
auth0,
baidu,
bitly,
box,
custom,
daccount,
dwolla,
email,
evernote-sandbox,
evernote,
exact,
facebook,
fitbit,
github,
google-apps,
google-oauth2,
instagram,
ip,
line,
linkedin,
oauth1,
oauth2,
office365,
oidc,
okta,
paypal,
paypal-sandbox,
pingfederate,
planningcenter,
salesforce-community,
salesforce-sandbox,
salesforce,
samlp,
sharepoint,
shopify,
shop,
sms,
soundcloud,
thirtysevensignals,
twitter,
untappd,
vkontakte,
waad,
weibo,
windowslive,
wordpress,
yahoo,
yandex
connection_id
string

connection_id of the secondary user account being linked when more than one auth0 database provider exists.

Pattern: ^con_[A-Za-z0-9]{16}$
user_id
défaut:abc

user_id of the secondary user account being linked.

Minimum string length: 1

JWT for the secondary account being linked. If sending this parameter, provider, user_id, and connection_id must not be sent.

Réponse

Identity successfully added.

connection
string
défaut:twitter
requis

Connection name of this identity.

user_id
défaut:abc
requis

user_id of this identity.

Minimum string length: 1
provider
string
défaut:twitter
requis

Type of identity provider.

profileData
object
isSocial
boolean

Whether the identity provider is a social provider (true) or not (false).

access_token
string

IDP access token returned if scope read:user_idp_tokens is defined.

access_token_secret
string

IDP access token secret returned only if scope read:user_idp_tokens is defined.

refresh_token
string

IDP refresh token returned only if scope read:user_idp_tokens is defined.