Spaces:
Running
Running
Download src/services/github/get-device-code.ts from imspsycho/copilot-api: direct link, hf CLI and curl.
- Browser
- Download file 744 Bytes
-
https://huggingface.co/spaces/imspsycho/copilot-api/resolve/97a73c4e00f8e59ad1faf3fb74c28d9dbd106911/src/services/github/get-device-code.ts
- Command line
-
hf download hf://spaces/imspsycho/copilot-api@97a73c4e00f8e59ad1faf3fb74c28d9dbd106911/src/services/github/get-device-code.ts
-
curl -L -o get-device-code.ts https://huggingface.co/spaces/imspsycho/copilot-api/resolve/97a73c4e00f8e59ad1faf3fb74c28d9dbd106911/src/services/github/get-device-code.ts
744 Bytes
| import { | |
| GITHUB_APP_SCOPES, | |
| GITHUB_BASE_URL, | |
| GITHUB_CLIENT_ID, | |
| standardHeaders, | |
| } from "~/lib/api-config" | |
| import { HTTPError } from "~/lib/error" | |
| export async function getDeviceCode(): Promise<DeviceCodeResponse> { | |
| const response = await fetch(`${GITHUB_BASE_URL}/login/device/code`, { | |
| method: "POST", | |
| headers: standardHeaders(), | |
| body: JSON.stringify({ | |
| client_id: GITHUB_CLIENT_ID, | |
| scope: GITHUB_APP_SCOPES, | |
| }), | |
| }) | |
| if (!response.ok) throw new HTTPError("Failed to get device code", response) | |
| return (await response.json()) as DeviceCodeResponse | |
| } | |
| export interface DeviceCodeResponse { | |
| device_code: string | |
| user_code: string | |
| verification_uri: string | |
| expires_in: number | |
| interval: number | |
| } | |