Initialize WebAuthn registration
curl --request POST \
--url https://{tenant_id}.hanko.io/webauthn/registration/initialize \
--cookie hanko=import requests
url = "https://{tenant_id}.hanko.io/webauthn/registration/initialize"
headers = {"cookie": "hanko="}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {cookie: 'hanko='}};
fetch('https://{tenant_id}.hanko.io/webauthn/registration/initialize', 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://{tenant_id}.hanko.io/webauthn/registration/initialize",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_COOKIE => "hanko=",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{tenant_id}.hanko.io/webauthn/registration/initialize"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("cookie", "hanko=")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{tenant_id}.hanko.io/webauthn/registration/initialize")
.header("cookie", "hanko=")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant_id}.hanko.io/webauthn/registration/initialize")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'hanko='
response = http.request(request)
puts response.read_body{
"publicKey": {
"rp": {
"name": "Hanko Authentication Service",
"id": "localhost"
},
"user": {
"id": "pPQT9rwJRD7gVncsnCDNyN",
"name": "user@example.com",
"displayName": "user@example.com"
},
"challenge": "7qmkJUXR0dOFnsW48evX3qKdCzlGjvvqAAvMDN+KTN0=",
"pubKeyCredParams": [
{
"type": "public-key",
"alg": -7
}
],
"timeout": 60000,
"authenticatorSelection": {
"authenticatorAttachment": "platform",
"requireResidentKey": true,
"residentKey": "preferred",
"userVerification": "required"
},
"attestation": "none"
}
}{
"code": 400,
"message": "Bad Request"
}{
"code": 422,
"message": "Unprocessable Entity"
}{
"code": 500,
"message": "Internal Server Error"
}WebAuthn
Initialize WebAuthn registration
deprecated
Initialize a registration with Webauthn.
POST
/
webauthn
/
registration
/
initialize
Initialize WebAuthn registration
curl --request POST \
--url https://{tenant_id}.hanko.io/webauthn/registration/initialize \
--cookie hanko=import requests
url = "https://{tenant_id}.hanko.io/webauthn/registration/initialize"
headers = {"cookie": "hanko="}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {cookie: 'hanko='}};
fetch('https://{tenant_id}.hanko.io/webauthn/registration/initialize', 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://{tenant_id}.hanko.io/webauthn/registration/initialize",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_COOKIE => "hanko=",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{tenant_id}.hanko.io/webauthn/registration/initialize"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("cookie", "hanko=")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{tenant_id}.hanko.io/webauthn/registration/initialize")
.header("cookie", "hanko=")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant_id}.hanko.io/webauthn/registration/initialize")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'hanko='
response = http.request(request)
puts response.read_body{
"publicKey": {
"rp": {
"name": "Hanko Authentication Service",
"id": "localhost"
},
"user": {
"id": "pPQT9rwJRD7gVncsnCDNyN",
"name": "user@example.com",
"displayName": "user@example.com"
},
"challenge": "7qmkJUXR0dOFnsW48evX3qKdCzlGjvvqAAvMDN+KTN0=",
"pubKeyCredParams": [
{
"type": "public-key",
"alg": -7
}
],
"timeout": 60000,
"authenticatorSelection": {
"authenticatorAttachment": "platform",
"requireResidentKey": true,
"residentKey": "preferred",
"userVerification": "required"
},
"attestation": "none"
}
}{
"code": 400,
"message": "Bad Request"
}{
"code": 422,
"message": "Unprocessable Entity"
}{
"code": 500,
"message": "Internal Server Error"
}Deprecated. Please use the Flow API instead. What’s the Flow API?.
navigator.credentials.create().
The Webauthn API uses binary data represented by ArrayBuffers for certain input/output values.
The Hanko API returns these values as base64url-encoded, so they must be converted to ArrayBuffers
when passed to the Webauthn API. Similarly, Webauthn API output must be converted to base64url-encoded values
when passed to the Hanko API (e.g. using the webauthn-json library).
Was this page helpful?
⌘I