Documentation Index
Fetch the complete documentation index at: https://docs.danubeai.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Polls for the result of a device authorization flow. The agent should call this endpoint every 5 seconds (the interval from the device code response) until it receives an API key or the code expires.
No authentication required.
Body Parameters
Response
Success (200) — User has authorized
The API key to use for future requests (e.g., dk_abc123...)
First 8 characters of the key
Pending (428) — User hasn’t authorized yet
{
"detail": "authorization_pending"
}
Keep polling every interval seconds.
Expired (410) — Code has expired or been used
{
"detail": "expired_token"
}
Start a new flow with Create Device Code.
Example
# Poll every 5 seconds
curl -X POST "https://api.danubeai.com/v1/auth/device/token" \
-H "Content-Type: application/json" \
-d '{"device_code": "dc_a1b2c3d4e5f6..."}'
{
"api_key": "dk_a1b2c3d4e5f6g7h8i9j0...",
"key_prefix": "dk_a1b2c"
}
Polling Logic
import time, requests
# Step 1: Get device code
resp = requests.post("https://api.danubeai.com/v1/auth/device/code",
json={"client_name": "My Agent"})
data = resp.json()
print(f"Enter code {data['user_code']} at {data['verification_url']}")
# Step 2: Poll for token
while True:
time.sleep(data["interval"])
poll = requests.post("https://api.danubeai.com/v1/auth/device/token",
json={"device_code": data["device_code"]})
if poll.status_code == 200:
api_key = poll.json()["api_key"]
print(f"Authorized! API key: {api_key[:12]}...")
break
elif poll.status_code == 428:
continue # Still waiting
else:
print("Code expired, start over")
break