Exchange a CLI authorization for a session credential
const url = 'https://api.aetherpush.com/v1/auth/cli/token';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"grantType":"authorization_code","code":"example","codeVerifier":"example","redirectUri":"example","deviceCode":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.aetherpush.com/v1/auth/cli/token \ --header 'Content-Type: application/json' \ --data '{ "grantType": "authorization_code", "code": "example", "codeVerifier": "example", "redirectUri": "example", "deviceCode": "example" }'The only endpoint that returns the CLI’s bearer token. Both grants are single use: a replay, a mismatched verifier, or a mismatched redirect URI terminates the request rather than merely failing.
For device_code, the pending states authorization_pending and
slow_down are returned with HTTP 400 per RFC 8628 and are expected
during normal polling. The RFC 8628 error codes appear on 400 only;
429 and 500 carry the standard { error, requestId } envelope with a
human-readable message, so branch on the status code first.
Request Bodyrequired
Section titled “Request Bodyrequired”Either an authorization-code exchange (loopback flow) or a device-code poll. The grant type selects which other fields are required.
object
Authorization code from the loopback redirect. Required for authorization_code.
The original PKCE verifier. Required for authorization_code.
Must byte-match the URI registered when the request was created.
Required for device_code.
Responses
Section titled “Responses”Credential issued.
object
The session bearer. Returned only here, only once, and never to the browser. Non-prefixed, so it resolves through the access-key path.
Identifies this device for DELETE /v1/cli/devices/{credentialId}.
object
Example
{ "expires": 1792049845916, "account": { "email": "user@example.com" }}Pending, throttled, denied, expired, or invalid.
RFC 8628 error codes. authorization_pending and slow_down are normal polling states, not failures.
object
Also returned in the X-Request-Id header.
Example
{ "error": "authorization_pending"}Too many token requests from this address.
object
Human-readable error message.
Unique identifier for the request, also exposed as the X-Request-Id response header.
Example
{ "error": "The requested resource was not found.", "requestId": "req_abc123"}Internal server error.
object
Human-readable error message.
Unique identifier for the request, also exposed as the X-Request-Id response header.
Example
{ "error": "The requested resource was not found.", "requestId": "req_abc123"}