Before you begin
Before you can implement flexible connection switching, ensure the following requirements are met:-
Use Universal Login.
- This feature is not available for custom login pages.
- Configure a custom domain.
- Enable the following for your application:
Implement flexible connection switching
To implement this feature, use the Auth0 Management API to configure custom signup and login prompt partials. Partials refer to custom code inserted into an entry point within a prompt screen, such as the login screen. To learn more, review Customize Signup and Login Prompts. To implement flexible connection switching, you will configure custom prompt partials with the following parameters:| Parameter | Description | Example |
|---|---|---|
state | Renders the current page’s state value, which is opaque and used for security purposes. To learn more about current screen information, review Customize Univeral Login Page Templates. | <input type=‘hidden’ name=‘state’ value=''> |
connection | Name and type of the connection. For passwordless connections, value is either email or sms. | <input type=‘hidden’ name=‘connection’ value=‘email’> |
In the code samples below, ensure you replace the placeholders with the appropriate values:
- Replace
{yourDomain}withyourdomain.auth0.com. - Replace
{mgmtApiToken}with your access token.
Configure signup prompt
You can configure thesignup-password prompt using the Set partials for a prompt endpoint:
curl --request PUT \
--url 'https://{yourDomain}/api/v2/prompts/signup-password/partials' \
--header 'authorization: Bearer {mgmtApiToken}' \
--header 'content-type: application/json' \
--data '{"signup-password":{"form-footer-start":" Send a secure code by email "}}'
var client = new RestClient("https://{yourDomain}/api/v2/prompts/signup-password/partials");
var request = new RestRequest(Method.PUT);
request.AddHeader("authorization", "Bearer {mgmtApiToken}");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"signup-password\":{\"form-footer-start\":\" Send a secure code by email \"}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://{yourDomain}/api/v2/prompts/signup-password/partials"
payload := strings.NewReader("{\"signup-password\":{\"form-footer-start\":\"<form method=\\\"post\\\" data-form-secondary=\\\"true\\\"><input type=\\\"hidden\\\" name=\\\"state\\\" value=\\\"{{state}}\\\"> <input type=\\\"hidden\\\" name=\\\"connection\\\" value=\\\"email\\\"> <button type=\\\"submit\\\" id=\\\"switchConnectionButton\\\" style=\\\"background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;\\\" data-action-button-secondary=\\\"true\\\"> <span>Send a secure code by email</span> </button></form>\"}}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("authorization", "Bearer {mgmtApiToken}")
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse response = Unirest.put("https://{yourDomain}/api/v2/prompts/signup-password/partials")
.header("authorization", "Bearer {mgmtApiToken}")
.header("content-type", "application/json")
.body("{\"signup-password\":{\"form-footer-start\":\" Send a secure code by email \"}}")
.asString();
var axios = require("axios").default;
var options = {
method: 'PUT',
url: 'https://{yourDomain}/api/v2/prompts/signup-password/partials',
headers: {authorization: 'Bearer {mgmtApiToken}', 'content-type': 'application/json'},
data: {
'signup-password': {
'form-footer-start': '<form method="post" data-form-secondary="true"><input type="hidden" name="state" value="{{state}}"> <input type="hidden" name="connection" value="email"> <button type="submit" id="switchConnectionButton" style="background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;" data-action-button-secondary="true"> <span>Send a secure code by email</span> </button></form>'
}
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"authorization": @"Bearer {mgmtApiToken}",
@"content-type": @"application/json" };
NSDictionary *parameters = @{ @"signup-password": @{ @"form-footer-start": @"<form method=\"post\" data-form-secondary=\"true\"><input type=\"hidden\" name=\"state\" value=\"{{state}}\"> <input type=\"hidden\" name=\"connection\" value=\"email\"> <button type=\"submit\" id=\"switchConnectionButton\" style=\"background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;\" data-action-button-secondary=\"true\"> <span>Send a secure code by email</span> </button></form>" } };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://{yourDomain}/api/v2/prompts/signup-password/partials"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"PUT"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{yourDomain}/api/v2/prompts/signup-password/partials",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "{\"signup-password\":{\"form-footer-start\":\"<form method=\\\"post\\\" data-form-secondary=\\\"true\\\"><input type=\\\"hidden\\\" name=\\\"state\\\" value=\\\"{{state}}\\\"> <input type=\\\"hidden\\\" name=\\\"connection\\\" value=\\\"email\\\"> <button type=\\\"submit\\\" id=\\\"switchConnectionButton\\\" style=\\\"background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;\\\" data-action-button-secondary=\\\"true\\\"> <span>Send a secure code by email</span> </button></form>\"}}",
CURLOPT_HTTPHEADER => [
"authorization: Bearer {mgmtApiToken}",
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import http.client
conn = http.client.HTTPSConnection("")
payload = "{\"signup-password\":{\"form-footer-start\":\"<form method=\\\"post\\\" data-form-secondary=\\\"true\\\"><input type=\\\"hidden\\\" name=\\\"state\\\" value=\\\"{{state}}\\\"> <input type=\\\"hidden\\\" name=\\\"connection\\\" value=\\\"email\\\"> <button type=\\\"submit\\\" id=\\\"switchConnectionButton\\\" style=\\\"background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;\\\" data-action-button-secondary=\\\"true\\\"> <span>Send a secure code by email</span> </button></form>\"}}"
headers = {
'authorization': "Bearer {mgmtApiToken}",
'content-type': "application/json"
}
conn.request("PUT", "/{yourDomain}/api/v2/prompts/signup-password/partials", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://{yourDomain}/api/v2/prompts/signup-password/partials")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Put.new(url)
request["authorization"] = 'Bearer {mgmtApiToken}'
request["content-type"] = 'application/json'
request.body = "{\"signup-password\":{\"form-footer-start\":\"<form method=\\\"post\\\" data-form-secondary=\\\"true\\\"><input type=\\\"hidden\\\" name=\\\"state\\\" value=\\\"{{state}}\\\"> <input type=\\\"hidden\\\" name=\\\"connection\\\" value=\\\"email\\\"> <button type=\\\"submit\\\" id=\\\"switchConnectionButton\\\" style=\\\"background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;\\\" data-action-button-secondary=\\\"true\\\"> <span>Send a secure code by email</span> </button></form>\"}}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"authorization": "Bearer {mgmtApiToken}",
"content-type": "application/json"
]
let parameters = ["signup-password": ["form-footer-start": "<form method=\"post\" data-form-secondary=\"true\"><input type=\"hidden\" name=\"state\" value=\"{{state}}\"> <input type=\"hidden\" name=\"connection\" value=\"email\"> <button type=\"submit\" id=\"switchConnectionButton\" style=\"background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;\" data-action-button-secondary=\"true\"> <span>Send a secure code by email</span> </button></form>"]] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://{yourDomain}/api/v2/prompts/signup-password/partials")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
signup-password screen. When a user selects this button, it submits a form body containing the login state parameter and the name of the desired connection.
Configure login prompts
For best results, configuring the login prompt for both password and passwordless connections is recommended. You can configure thelogin-password prompt using the Set partials for a prompt endpoint:
curl --request PUT \
--url 'https://{yourDomain}/api/v2/prompts/login-password/partials' \
--header 'authorization: Bearer {mgmtApiToken}' \
--header 'content-type: application/json' \
--data '{"login-password":{"form-footer-start":" Send a secure code by email "}}'
var client = new RestClient("https://{yourDomain}/api/v2/prompts/login-password/partials");
var request = new RestRequest(Method.PUT);
request.AddHeader("authorization", "Bearer {mgmtApiToken}");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"login-password\":{\"form-footer-start\":\" Send a secure code by email \"}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://{yourDomain}/api/v2/prompts/login-password/partials"
payload := strings.NewReader("{\"login-password\":{\"form-footer-start\":\"<form method='post' data-form-secondary='true'><input type='hidden' name='state' value='{{state}}'> <input type='hidden' name='connection' value='email'> <button type='submit' id='switchConnectionButton' style='background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;' data-action-button-secondary='true'> <span>Send a secure code by email</span> </button></form>\"}}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("authorization", "Bearer {mgmtApiToken}")
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}n(string(body))
}
HttpResponse response = Unirest.put("https://{yourDomain}/api/v2/prompts/login-password/partials")
.header("authorization", "Bearer {mgmtApiToken}")
.header("content-type", "application/json")
.body("{\"login-password\":{\"form-footer-start\":\" Send a secure code by email \"}}")
.asString();
var axios = require("axios").default;
var options = {
method: 'PUT',
url: 'https://{yourDomain}/api/v2/prompts/login-password/partials',
headers: {authorization: 'Bearer {mgmtApiToken}', 'content-type': 'application/json'},
data: {
'login-password': {
'form-footer-start': '<form method=\'post\' data-form-secondary=\'true\'><input type=\'hidden\' name=\'state\' value=\'{{state}}\'> <input type=\'hidden\' name=\'connection\' value=\'email\'> <button type=\'submit\' id=\'switchConnectionButton\' style=\'background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;\' data-action-button-secondary=\'true\'> <span>Send a secure code by email</span> </button></form>'
}
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"authorization": @"Bearer {mgmtApiToken}",
@"content-type": @"application/json" };
NSDictionary *parameters = @{ @"login-password": @{ @"form-footer-start": @"<form method='post' data-form-secondary='true'><input type='hidden' name='state' value='{{state}}'> <input type='hidden' name='connection' value='email'> <button type='submit' id='switchConnectionButton' style='background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;' data-action-button-secondary='true'> <span>Send a secure code by email</span> </button></form>" } };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://{yourDomain}/api/v2/prompts/login-password/partials"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"PUT"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{yourDomain}/api/v2/prompts/login-password/partials",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "{\"login-password\":{\"form-footer-start\":\"<form method='post' data-form-secondary='true'><input type='hidden' name='state' value='{{state}}'> <input type='hidden' name='connection' value='email'> <button type='submit' id='switchConnectionButton' style='background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;' data-action-button-secondary='true'> <span>Send a secure code by email</span> </button></form>\"}}",
CURLOPT_HTTPHEADER => [
"authorization: Bearer {mgmtApiToken}",
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import http.client
conn = http.client.HTTPSConnection("")
payload = "{\"login-password\":{\"form-footer-start\":\"<form method='post' data-form-secondary='true'><input type='hidden' name='state' value='{{state}}'> <input type='hidden' name='connection' value='email'> <button type='submit' id='switchConnectionButton' style='background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;' data-action-button-secondary='true'> <span>Send a secure code by email</span> </button></form>\"}}"
headers = {
'authorization': "Bearer {mgmtApiToken}",
'content-type': "application/json"
}
conn.request("PUT", "/{yourDomain}/api/v2/prompts/login-password/partials", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://{yourDomain}/api/v2/prompts/login-password/partials")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Put.new(url)
request["authorization"] = 'Bearer {mgmtApiToken}'
request["content-type"] = 'application/json'
request.body = "{\"login-password\":{\"form-footer-start\":\"<form method='post' data-form-secondary='true'><input type='hidden' name='state' value='{{state}}'> <input type='hidden' name='connection' value='email'> <button type='submit' id='switchConnectionButton' style='background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;' data-action-button-secondary='true'> <span>Send a secure code by email</span> </button></form>\"}}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"authorization": "Bearer {mgmtApiToken}",
"content-type": "application/json"
]
let parameters = ["login-password": ["form-footer-start": "<form method='post' data-form-secondary='true'><input type='hidden' name='state' value='{{state}}'> <input type='hidden' name='connection' value='email'> <button type='submit' id='switchConnectionButton' style='background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;' data-action-button-secondary='true'> <span>Send a secure code by email</span> </button></form>"]] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://{yourDomain}/api/v2/prompts/login-password/partials")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
login-password screen. When a user selects this button, it submits a form body containing the login state parameter and the name of the desired connection.
Similarly, you can configure the login-passwordless prompt using the Set partials for a prompt endpoint:
curl --request PUT \
--url 'https://{yourDomain}/api/v2/prompts/login-passwordless/partials' \
--header 'authorization: Bearer {mgmtApiToken}' \
--header 'content-type: application/json' \
--data '{"login-passwordless-email-code":{"form-footer-start":" Use Password Instead "}}'
var client = new RestClient("https://{yourDomain}/api/v2/prompts/login-passwordless/partials");
var request = new RestRequest(Method.PUT);
request.AddHeader("authorization", "Bearer {mgmtApiToken}");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"login-passwordless-email-code\":{\"form-footer-start\":\" Use Password Instead \"}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://{yourDomain}/api/v2/prompts/login-passwordless/partials"
payload := strings.NewReader("{\"login-passwordless-email-code\":{\"form-footer-start\":\"<form method='post' data-form-secondary='true'><input type='hidden' name='state' value='{{state}}'> <input type='hidden' name='connection' value='Username-Password-Authentication'> <button type='submit' id='switchConnectionButton' style='background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;' data-action-button-secondary='true'> <span>Use Password Instead</span> </button></form>\"}}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("authorization", "Bearer {mgmtApiToken}")
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse response = Unirest.put("https://{yourDomain}/api/v2/prompts/login-passwordless/partials")
.header("authorization", "Bearer {mgmtApiToken}")
.header("content-type", "application/json")
.body("{\"login-passwordless-email-code\":{\"form-footer-start\":\" Use Password Instead \"}}")
.asString();
var axios = require("axios").default;
var options = {
method: 'PUT',
url: 'https://{yourDomain}/api/v2/prompts/login-passwordless/partials',
headers: {authorization: 'Bearer {mgmtApiToken}', 'content-type': 'application/json'},
data: {
'login-passwordless-email-code': {
'form-footer-start': '<form method=\'post\' data-form-secondary=\'true\'><input type=\'hidden\' name=\'state\' value=\'{{state}}\'> <input type=\'hidden\' name=\'connection\' value=\'Username-Password-Authentication\'> <button type=\'submit\' id=\'switchConnectionButton\' style=\'background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;\' data-action-button-secondary=\'true\'> <span>Use Password Instead</span> </button></form>'
}
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"authorization": @"Bearer {mgmtApiToken}",
@"content-type": @"application/json" };
NSDictionary *parameters = @{ @"login-passwordless-email-code": @{ @"form-footer-start": @"<form method='post' data-form-secondary='true'><input type='hidden' name='state' value='{{state}}'> <input type='hidden' name='connection' value='Username-Password-Authentication'> <button type='submit' id='switchConnectionButton' style='background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;' data-action-button-secondary='true'> <span>Use Password Instead</span> </button></form>" } };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://{yourDomain}/api/v2/prompts/login-passwordless/partials"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"PUT"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{yourDomain}/api/v2/prompts/login-passwordless/partials",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "{\"login-passwordless-email-code\":{\"form-footer-start\":\"<form method='post' data-form-secondary='true'><input type='hidden' name='state' value='{{state}}'> <input type='hidden' name='connection' value='Username-Password-Authentication'> <button type='submit' id='switchConnectionButton' style='background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;' data-action-button-secondary='true'> <span>Use Password Instead</span> </button></form>\"}}",
CURLOPT_HTTPHEADER => [
"authorization: Bearer {mgmtApiToken}",
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import http.client
conn = http.client.HTTPSConnection("")
payload = "{\"login-passwordless-email-code\":{\"form-footer-start\":\"<form method='post' data-form-secondary='true'><input type='hidden' name='state' value='{{state}}'> <input type='hidden' name='connection' value='Username-Password-Authentication'> <button type='submit' id='switchConnectionButton' style='background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;' data-action-button-secondary='true'> <span>Use Password Instead</span> </button></form>\"}}"
headers = {
'authorization': "Bearer {mgmtApiToken}",
'content-type': "application/json"
}
conn.request("PUT", "/{yourDomain}/api/v2/prompts/login-passwordless/partials", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://{yourDomain}/api/v2/prompts/login-passwordless/partials")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Put.new(url)
request["authorization"] = 'Bearer {mgmtApiToken}'
request["content-type"] = 'application/json'
request.body = "{\"login-passwordless-email-code\":{\"form-footer-start\":\"<form method='post' data-form-secondary='true'><input type='hidden' name='state' value='{{state}}'> <input type='hidden' name='connection' value='Username-Password-Authentication'> <button type='submit' id='switchConnectionButton' style='background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;' data-action-button-secondary='true'> <span>Use Password Instead</span> </button></form>\"}}"
response = http.request(request)
puts response.read_body
import Foundation
let headers = [
"authorization": "Bearer {mgmtApiToken}",
"content-type": "application/json"
]
let parameters = ["login-passwordless-email-code": ["form-footer-start": "<form method='post' data-form-secondary='true'><input type='hidden' name='state' value='{{state}}'> <input type='hidden' name='connection' value='Username-Password-Authentication'> <button type='submit' id='switchConnectionButton' style='background: #635dff; width: 100%; padding: 12px 16px; border: none; color: white;' data-action-button-secondary='true'> <span>Use Password Instead</span> </button></form>"]] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://{yourDomain}/api/v2/prompts/login-passwordless/partials")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()