requestDeviceCode (src/deviceAuth.ts)

clawhub · packages/clawhub/src/deviceAuth.ts · typescript · MIT
auth

TypeScript helpers for GitHub Device Flow authentication, requesting device codes and polling for tokens.

// Source: https://github.com/openclaw/clawhub | License: MIT | Copyright 2026 Peter Steinberger
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * GitHub Device Flow authentication for headless environments.
 *
 * Implements RFC 8628 / GitHub's Device Flow:
 * https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#device-flow
 *
 * This allows CLI authentication without a browser redirect to localhost,
 * enabling headless agents and remote servers to authenticate.
 */

type DeviceCodeResponse = {
  device_code: string;
  user_code: string;
  verification_uri: string;
  expires_in: number;
  interval: number;
};

type DeviceTokenResponse = {
  access_token: string;
  token_type: string;
  scope: string;
};

type DeviceTokenErrorResponse 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key