| 222 | } |
| 223 | |
| 224 | export function printDeviceCodePrompt(code: string, verificationUrl = DEVICE_LOGIN_URL): void { |
| 225 | console.log(` |
| 226 | Welcome to Codex |
| 227 | |
| 228 | Follow these steps to sign in with ChatGPT using device code authorization: |
| 229 | |
| 230 | 1. Open this link in your browser and sign in to your account |
| 231 | ${verificationUrl} |
| 232 | |
| 233 | 2. Enter this one-time code (expires in 15 minutes) |
| 234 | ${code} |
| 235 | |
| 236 | Device codes are a common phishing target. Never share this code. |
| 237 | `) |
| 238 | } |
| 239 | |
| 240 | export async function pollForToken(deviceAuthId: string, userCode: string, interval: number): Promise<TokenResponse> { |
| 241 | const url = issuerPath("/api/accounts/deviceauth/token") |