Device Flow
curl --request POST \
--url https://api.superbox.ai/api/v1/auth/device/start \
--header 'Content-Type: application/json' \
--data '
{
"provider": "<string>",
"device_code": "<string>"
}
'import requests
url = "https://api.superbox.ai/api/v1/auth/device/start"
payload = {
"provider": "<string>",
"device_code": "<string>"
}
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({provider: '<string>', device_code: '<string>'})
};
fetch('https://api.superbox.ai/api/v1/auth/device/start', 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.superbox.ai/api/v1/auth/device/start",
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([
'provider' => '<string>',
'device_code' => '<string>'
]),
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.superbox.ai/api/v1/auth/device/start"
payload := strings.NewReader("{\n \"provider\": \"<string>\",\n \"device_code\": \"<string>\"\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.superbox.ai/api/v1/auth/device/start")
.header("Content-Type", "application/json")
.body("{\n \"provider\": \"<string>\",\n \"device_code\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.superbox.ai/api/v1/auth/device/start")
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 \"provider\": \"<string>\",\n \"device_code\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"device_code": "<string>",
"user_code": "<string>",
"verification_uri": "<string>",
"expires_in": 123,
"interval": 123
}Auth API
Device Flow
OAuth 2.0 device authorization flow used by the SuperBox CLI
POST
/
api
/
v1
/
auth
/
device
/
start
Device Flow
curl --request POST \
--url https://api.superbox.ai/api/v1/auth/device/start \
--header 'Content-Type: application/json' \
--data '
{
"provider": "<string>",
"device_code": "<string>"
}
'import requests
url = "https://api.superbox.ai/api/v1/auth/device/start"
payload = {
"provider": "<string>",
"device_code": "<string>"
}
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({provider: '<string>', device_code: '<string>'})
};
fetch('https://api.superbox.ai/api/v1/auth/device/start', 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.superbox.ai/api/v1/auth/device/start",
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([
'provider' => '<string>',
'device_code' => '<string>'
]),
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.superbox.ai/api/v1/auth/device/start"
payload := strings.NewReader("{\n \"provider\": \"<string>\",\n \"device_code\": \"<string>\"\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.superbox.ai/api/v1/auth/device/start")
.header("Content-Type", "application/json")
.body("{\n \"provider\": \"<string>\",\n \"device_code\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.superbox.ai/api/v1/auth/device/start")
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 \"provider\": \"<string>\",\n \"device_code\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"device_code": "<string>",
"user_code": "<string>",
"verification_uri": "<string>",
"expires_in": 123,
"interval": 123
}Overview
The device authorization flow lets the SuperBox CLI authenticate users without embedding browser logic. The CLI obtains a device code, displays a URL for the user to visit, then polls until the user completes login.This is the flow used internally by
superbox auth login --provider google and superbox auth login --provider github.Step 1 - Start Device Session
Request a device code and user code.Endpoint
POST /api/v1/auth/device/start
Request Body
string
required
OAuth provider:
google or githubExample Request
curl -X POST https://api.superbox.ai/api/v1/auth/device/start \
-H "Content-Type: application/json" \
-d '{"provider": "google"}'
import requests
response = requests.post(
"https://api.superbox.ai/api/v1/auth/device/start",
json={"provider": "google"},
)
data = response.json()
print(f"Visit: {data['verification_uri']}")
print(f"Code: {data['user_code']}")
Response (200)
string
Internal code used when polling. Keep this private.
string
Short code the user enters on the verification page (e.g.,
ABCD-1234).string
URL for the user to open in a browser.
number
Seconds until the device code expires (default: 600).
number
Recommended polling interval in seconds (default: 5).
{
"device_code": "GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS",
"user_code": "ABCD-1234",
"verification_uri": "https://superbox.1mindlabs.org/device",
"expires_in": 600,
"interval": 5
}
Step 2 - User Authorizes
Display theverification_uri and user_code to the user. They open the URL in a browser, log in with the selected provider, and enter the code.
GET /api/v1/auth/device
Step 3 - Poll for Token
Poll until the user completes authorization.Endpoint
POST /api/v1/auth/device/poll
Request Body
string
required
The device code returned in Step 1
Status Codes
| Status | Meaning |
|---|---|
200 | Authorization complete. Response contains the token. |
428 | Still waiting. Continue polling. |
429 | Polling too fast. Increase interval. |
400 | Device code expired or invalid. |
Example Request
curl -X POST https://api.superbox.ai/api/v1/auth/device/poll \
-H "Content-Type: application/json" \
-d '{"device_code": "GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS"}'
import requests
import time
device_code = "GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS"
interval = 5
while True:
response = requests.post(
"https://api.superbox.ai/api/v1/auth/device/poll",
json={"device_code": device_code},
)
if response.status_code == 200:
data = response.json()
print("Authentication successful!")
print(f"Token: {data['id_token']}")
break
elif response.status_code == 428:
print("Waiting for authorization...")
time.sleep(interval)
elif response.status_code == 429:
interval += 5
time.sleep(interval)
else:
print(f"Error: {response.json()}")
break
Success Response (200)
{
"id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6...",
"refresh_token": "AMf-vByW3...",
"expires_in": 3600,
"email": "user@example.com",
"local_id": "abc123def456"
}
Pending Response (428)
{
"status": "pending",
"message": "Authorization pending"
}