Spaces:
Running
Running
Download src/services/github/get-copilot-token.ts from imspsycho/copilot-api: direct link, hf CLI and curl.
- Browser
- Download file 614 Bytes
-
https://huggingface.co/spaces/imspsycho/copilot-api/resolve/97a73c4e00f8e59ad1faf3fb74c28d9dbd106911/src/services/github/get-copilot-token.ts
- Command line
-
hf download hf://spaces/imspsycho/copilot-api@97a73c4e00f8e59ad1faf3fb74c28d9dbd106911/src/services/github/get-copilot-token.ts
-
curl -L -o get-copilot-token.ts https://huggingface.co/spaces/imspsycho/copilot-api/resolve/97a73c4e00f8e59ad1faf3fb74c28d9dbd106911/src/services/github/get-copilot-token.ts
614 Bytes
| import { GITHUB_API_BASE_URL, githubHeaders } from "~/lib/api-config" | |
| import { HTTPError } from "~/lib/error" | |
| import { state } from "~/lib/state" | |
| export const getCopilotToken = async () => { | |
| const response = await fetch( | |
| `${GITHUB_API_BASE_URL}/copilot_internal/v2/token`, | |
| { | |
| headers: githubHeaders(state), | |
| }, | |
| ) | |
| if (!response.ok) throw new HTTPError("Failed to get Copilot token", response) | |
| return (await response.json()) as GetCopilotTokenResponse | |
| } | |
| // Trimmed for the sake of simplicity | |
| interface GetCopilotTokenResponse { | |
| expires_at: number | |
| refresh_in: number | |
| token: string | |
| } | |