Poll for the result of a CLI device-authorization flow
curl -X POST 'https://dashboard.justcrawl.io/api/v1/cli-auth/poll' \ -H 'Content-Type: application/json' \ -d '{"device_code":"<your-device-code>"}'import time, requestswhile True: r = requests.post( 'https://dashboard.justcrawl.io/api/v1/cli-auth/poll', json={'device_code': device_code}, ) r.raise_for_status() body = r.json() if body['status'] == 'approved': api_key = body['api_key'] # persist immediately break time.sleep(2)while (true) { const res = await fetch('https://dashboard.justcrawl.io/api/v1/cli-auth/poll', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ device_code: deviceCode }), }); if (!res.ok) throw new Error(`${res.status} ${await res.text()}`); const body = await res.json(); if (body.status === 'approved') { const apiKey = body.api_key; // persist immediately break; } await new Promise(r => setTimeout(r, 2000));}Final leg of the device-authorization flow. The CLI polls this endpoint
at the interval returned by /cli-auth/start (currently every 2s);
once the user approves in the browser, this endpoint returns the API
key plaintext exactly ONCE. A second poll after success returns 410
auth_code_consumed — the CLI must persist the key on the first
success response. Body branches:
{ status: "pending" } while the user hasn’t approved yet;
{ status: "approved", api_key, org_id, org_name, user_email } on the
single success read. Subject to cliAuthLimiter. This is the endpoint
jc auth login --browser (master plan Phase 0.5) loops on after
opening the verification URL.
Request Body required
Section titled “Request Body required ”object
Example generated
{ "device_code": "example"}Responses
Section titled “ Responses ”Poll result. Either still-pending or approved-with-key.
Validation failed — request body or query is missing/invalid
object
Example
{ "error": "Missing or invalid \"url\" field"}Unknown device_code.
Code expired or already consumed (post-approval second poll).
Unexpected server error. Logs and PostHog $exception capture
object
Example
{ "error": "Something went wrong"}