Login Finalize
Finalize login
Finalize a login flow by exchanging a challenge token for session tokens (access + refresh).
POST
/
v1
/
session
/
login
/
finalize
Finalize login
curl --request POST \
--url https://{appId}.session.prelude.dev/v1/session/login/finalize \
--header 'Content-Type: application/json' \
--data '
{
"challenge_token": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
}
'import requests
url = "https://{appId}.session.prelude.dev/v1/session/login/finalize"
payload = {
"challenge_token": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
challenge_token: 'eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...',
code_verifier: 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk'
})
};
fetch('https://{appId}.session.prelude.dev/v1/session/login/finalize', 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://{appId}.session.prelude.dev/v1/session/login/finalize",
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([
'challenge_token' => 'eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...',
'code_verifier' => 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{appId}.session.prelude.dev/v1/session/login/finalize"
payload := strings.NewReader("{\n \"challenge_token\": \"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{appId}.session.prelude.dev/v1/session/login/finalize")
.header("Content-Type", "application/json")
.body("{\n \"challenge_token\": \"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.session.prelude.dev/v1/session/login/finalize")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"challenge_token\": \"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...",
"expires_at": 1717689600
}{
"code": "bad_request",
"type": "bad_request"
}{
"code": "invalid_dpop_proof",
"type": "unauthorized"
}{
"code": "auth_blocked",
"type": "forbidden"
}{
"code": "token_reused",
"type": "conflict"
}{
"code": "rate_limited",
"type": "rate_limited"
}{
"code": "internal",
"type": "internal"
}Headers
Optional refresh token from a previous session. When provided, the session associated with this token is revoked once the new session is established, so a re-login does not leave the old session dangling. Ignored when the token is missing or can no longer be resolved to an active session.
Body
application/json
The challenge token obtained from a login method.
Example:
"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9..."
PKCE code verifier matching the code_challenge originally sent
on the login flow (OAuth, standalone OTP, or migration).
Required when the challenge token carries a pkce_challenge
claim; ignored otherwise.
Example:
"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
⌘I
Finalize login
curl --request POST \
--url https://{appId}.session.prelude.dev/v1/session/login/finalize \
--header 'Content-Type: application/json' \
--data '
{
"challenge_token": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
}
'import requests
url = "https://{appId}.session.prelude.dev/v1/session/login/finalize"
payload = {
"challenge_token": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
challenge_token: 'eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...',
code_verifier: 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk'
})
};
fetch('https://{appId}.session.prelude.dev/v1/session/login/finalize', 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://{appId}.session.prelude.dev/v1/session/login/finalize",
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([
'challenge_token' => 'eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...',
'code_verifier' => 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{appId}.session.prelude.dev/v1/session/login/finalize"
payload := strings.NewReader("{\n \"challenge_token\": \"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{appId}.session.prelude.dev/v1/session/login/finalize")
.header("Content-Type", "application/json")
.body("{\n \"challenge_token\": \"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{appId}.session.prelude.dev/v1/session/login/finalize")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"challenge_token\": \"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...\",\n \"code_verifier\": \"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...",
"expires_at": 1717689600
}{
"code": "bad_request",
"type": "bad_request"
}{
"code": "invalid_dpop_proof",
"type": "unauthorized"
}{
"code": "auth_blocked",
"type": "forbidden"
}{
"code": "token_reused",
"type": "conflict"
}{
"code": "rate_limited",
"type": "rate_limited"
}{
"code": "internal",
"type": "internal"
}