Start browser login for the CLI
curl --request POST \
--url https://api.pyai.com/auth/cli/device \
--header 'Content-Type: application/json' \
--data '
{
"code_challenge": "<string>",
"code_challenge_method": "S256",
"client_name": "PyAI CLI"
}
'import requests
url = "https://api.pyai.com/auth/cli/device"
payload = {
"code_challenge": "<string>",
"code_challenge_method": "S256",
"client_name": "PyAI CLI"
}
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({
code_challenge: '<string>',
code_challenge_method: 'S256',
client_name: 'PyAI CLI'
})
};
fetch('https://api.pyai.com/auth/cli/device', 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://api.pyai.com/auth/cli/device",
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([
'code_challenge' => '<string>',
'code_challenge_method' => 'S256',
'client_name' => 'PyAI CLI'
]),
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://api.pyai.com/auth/cli/device"
payload := strings.NewReader("{\n \"code_challenge\": \"<string>\",\n \"code_challenge_method\": \"S256\",\n \"client_name\": \"PyAI CLI\"\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://api.pyai.com/auth/cli/device")
.header("Content-Type", "application/json")
.body("{\n \"code_challenge\": \"<string>\",\n \"code_challenge_method\": \"S256\",\n \"client_name\": \"PyAI CLI\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pyai.com/auth/cli/device")
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 \"code_challenge\": \"<string>\",\n \"code_challenge_method\": \"S256\",\n \"client_name\": \"PyAI CLI\"\n}"
response = http.request(request)
puts response.read_body{
"device_code": "<string>",
"user_code": "<string>",
"verification_uri": "<string>",
"verification_uri_complete": "<string>",
"expires_in": 600,
"interval": 5
}{
"title": "<string>",
"status": 123,
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}Identity
Start browser login for the CLI
Creates a ten-minute device grant bound to the CLI’s S256 verifier. Open verification_uri_complete in a browser, compare its user code with the terminal, then approve. The grant is rate limited per source network; no API key is required. Responses must not be cached.
POST
/
auth
/
cli
/
device
Start browser login for the CLI
curl --request POST \
--url https://api.pyai.com/auth/cli/device \
--header 'Content-Type: application/json' \
--data '
{
"code_challenge": "<string>",
"code_challenge_method": "S256",
"client_name": "PyAI CLI"
}
'import requests
url = "https://api.pyai.com/auth/cli/device"
payload = {
"code_challenge": "<string>",
"code_challenge_method": "S256",
"client_name": "PyAI CLI"
}
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({
code_challenge: '<string>',
code_challenge_method: 'S256',
client_name: 'PyAI CLI'
})
};
fetch('https://api.pyai.com/auth/cli/device', 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://api.pyai.com/auth/cli/device",
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([
'code_challenge' => '<string>',
'code_challenge_method' => 'S256',
'client_name' => 'PyAI CLI'
]),
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://api.pyai.com/auth/cli/device"
payload := strings.NewReader("{\n \"code_challenge\": \"<string>\",\n \"code_challenge_method\": \"S256\",\n \"client_name\": \"PyAI CLI\"\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://api.pyai.com/auth/cli/device")
.header("Content-Type", "application/json")
.body("{\n \"code_challenge\": \"<string>\",\n \"code_challenge_method\": \"S256\",\n \"client_name\": \"PyAI CLI\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pyai.com/auth/cli/device")
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 \"code_challenge\": \"<string>\",\n \"code_challenge_method\": \"S256\",\n \"client_name\": \"PyAI CLI\"\n}"
response = http.request(request)
puts response.read_body{
"device_code": "<string>",
"user_code": "<string>",
"verification_uri": "<string>",
"verification_uri_complete": "<string>",
"expires_in": 600,
"interval": 5
}{
"title": "<string>",
"status": 123,
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "<string>",
"detail": "<string>",
"request_id": "<string>"
}Body
application/json
Response
Device grant created. Keep device_code and the verifier private; only user_code belongs in the browser URL.