# pollDeviceToken

<!-- https://uncage.vercel.app/docs/api/agent/functions/polldevicetoken/ -->

```ts
function pollDeviceToken(o): Promise<{
  machineId: string;
  machineToken: string;
  site: {
     id: string;
     name: string;
     url: string;
  };
  status: "ok";
  transports: object[];
}>;
```

Defined in: agent/src/device.ts:118

Polls `/device/token` every `intervalSec` (RFC 8628: `slow_down` adds 5 s) until the user
approves, denies, or the code expires. The hub's values are clamped (interval 1–60 s, expiry at
most 30 min) so a misbehaving hub cannot make setup hang or hammer it.

## Parameters

| Parameter | Type |
| ------ | ------ |
| `o` | \{ `code`: \{ `deviceCode`: `string`; `expiresInSec`: `number`; `intervalSec`: `number`; `userCode`: `string`; `verificationUri`: `string`; \}; `fetch`: (`input`, `init?`) => `Promise`\<`Response`\>; `hubUrl`: `string`; `now?`: () => `number`; `sleep?`: (`ms`) => `Promise`\<`void`\>; \} |
| `o.code` | \{ `deviceCode`: `string`; `expiresInSec`: `number`; `intervalSec`: `number`; `userCode`: `string`; `verificationUri`: `string`; \} |
| `o.code.deviceCode` | `string` |
| `o.code.expiresInSec` | `number` |
| `o.code.intervalSec` | `number` |
| `o.code.userCode` | `string` |
| `o.code.verificationUri` | `string` |
| `o.fetch` | (`input`, `init?`) => `Promise`\<`Response`\> |
| `o.hubUrl` | `string` |
| `o.now?` | () => `number` |
| `o.sleep?` | (`ms`) => `Promise`\<`void`\> |

## Returns

`Promise`\<\{
  `machineId`: `string`;
  `machineToken`: `string`;
  `site`: \{
     `id`: `string`;
     `name`: `string`;
     `url`: `string`;
  \};
  `status`: `"ok"`;
  `transports`: `object`[];
\}\>
