Start two-factor setup
curl --request POST \
--url https://{host}/v1/me/two-factor-setups \
--header 'Authorization: Bearer <token>'const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{host}/v1/me/two-factor-setups', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{host}/v1/me/two-factor-setups",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}import requests
url = "https://{host}/v1/me/two-factor-setups"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text){
"data": {
"type": "two-factor-setups",
"attributes": {
"secret": "JBSWY3DPEHPK3PXP",
"otpauthUri": "otpauth://totp/Wristler:jeffrey%40example.test?secret=JBSWY3DPEHPK3PXP&issuer=Wristler"
}
}
}{
"errors": [
{
"status": "404",
"code": "watch_reserved",
"title": "Not Found",
"detail": "<string>",
"meta": {},
"source": {
"pointer": "/data/attributes/reference",
"parameter": "<string>"
}
}
],
"jsonapi": {
"version": "1.0"
}
}Account (Security)
Start two-factor setup
Scope: account-security:write
A secret to scan and the otpauth:// URI to draw a QR code from. Nothing is
stored on the account: it becomes real when somebody proves the secret reached
their phone, which is the next call.
The secret is held for 30 minutes, and enabling accepts only the secret this call handed out — a client cannot choose its own. Take longer than that and start here again.
POST
/
v1
/
me
/
two-factor-setups
Start two-factor setup
curl --request POST \
--url https://{host}/v1/me/two-factor-setups \
--header 'Authorization: Bearer <token>'const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{host}/v1/me/two-factor-setups', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{host}/v1/me/two-factor-setups",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}import requests
url = "https://{host}/v1/me/two-factor-setups"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text){
"data": {
"type": "two-factor-setups",
"attributes": {
"secret": "JBSWY3DPEHPK3PXP",
"otpauthUri": "otpauth://totp/Wristler:jeffrey%40example.test?secret=JBSWY3DPEHPK3PXP&issuer=Wristler"
}
}
}{
"errors": [
{
"status": "404",
"code": "watch_reserved",
"title": "Not Found",
"detail": "<string>",
"meta": {},
"source": {
"pointer": "/data/attributes/reference",
"parameter": "<string>"
}
}
],
"jsonapi": {
"version": "1.0"
}
}