Skip to content

POST /v1/auth/device/token

Exchanges an authorized device code or a refresh token for an access token and rotating refresh token. Accepts JSON and form-encoded bodies. While polling, wait at least interval seconds and increase the interval on slow_down. Store the new refresh token after every successful grant.

photon.auth.device.token(input: DeviceTokenInput, options?: RequestOptions): Promise<DeviceTokenOutput>
import { Photon } from "@photon-ai/api";

const photon = new Photon();
const result = await photon.auth.device.token({
  body: {
    device_code: "device_code",
    grant_type: "urn:ietf:params:oauth:grant-type:device_code",
  },
});
{
  "access_token": "string",
  "authentication_method": "string",
  "expires_in": 0,
  "refresh_token": "string",
  "user": {
    "email": "string",
    "first_name": null,
    "id": "string",
    "last_name": null
  }
}

Body

One of: DeviceCodeGrantRequest

device_codestringrequired

device_code returned by POST /v1/auth/device/code. Required for a device-code grant.

grant_typeunknownrequired

Selects the device authorization grant to poll or exchange a device code.

One of: RefreshTokenGrantRequest

grant_typeunknownrequired

Selects the refresh-token grant to obtain a new token pair.

refresh_tokenstringrequired

Most recently issued refresh token. Required for a refresh grant; replace it with the returned refresh_token after success.

Returns

200 Token pair (snake_case OAuth wire format). Body (form-encoded or JSON): grant_type=urn:ietf:params:oauth:grant-type:device_code with device_code, or grant_type=refresh_token with refresh_token. Refresh tokens rotate on every grant — always store the new one. DeviceTokenResponse

access_tokenstringrequired

Bearer access token for authenticated Photon API requests.

authentication_methodstring

Authentication method used for the device login, when returned. Omitted for refresh grants.

expires_innumberrequired

Access-token validity in seconds, derived from its expiry and issue times; defaults to 300 when unavailable.

refresh_tokenstringrequired

Refresh token for the next refresh grant. Tokens rotate on every grant; replace the stored value with this one.

userDeviceTokenResponseUserrequired

Profile of the authenticated user.