Skip to content

First Run Results in 403 Forbidden Error #1

@asyncButNeverAwaits

Description

@asyncButNeverAwaits

When running the application for the first time, it fails with a 403 Forbidden error during the Copilot token initialization. However, running the application a second time completes successfully.

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS D:\copilot-api> bun install
bun install v1.2.2 (c1708ea6)

+ typescript@5.7.3
+ @echristian/eslint-config@0.0.16
+ @types/bun@1.1.16
+ eslint@9.18.0
+ knip@5.43.1
+ citty@0.1.6
+ consola@3.4.0
+ fetch-event-stream@0.1.5
+ hono@4.6.18
+ ofetch@1.4.1
+ pathe@2.0.2
+ srvx@0.1.4

188 packages installed [25.22s]
PS D:\copilot-api> bun run start --port 8080 --emulate-streaming
$ NODE_ENV=production bun run ./src/main.ts --port "8080" --emulate-streaming
◐ Initializing App directory...                                                                             9:47:39 AM
✔ App directory initialized                                                                                9:47:39 AM
◐ Initializing GitHub authentication...                                                                     9:47:39 AM
ℹ Not logged in, getting new access token                                                                  9:47:40 AM
◐ Getting GitHub device code                                                                                9:47:40 AM
ℹ Please enter the code "XXXX-CD21" in https://github.com/login/device                                     9:47:40 AM
ℹ Got token ****************************************                                                       9:50:30 AM
ℹ Logged in as "XXXX"                                                                       9:50:30 AM
✔ GitHub authentication initialized                                                                        9:50:30 AM
◐ Initializing Copilot token...                                                                             9:50:30 AM

[9:50:30 AM]  ERROR  Failed to initialize Copilot token: [FetchError: [GET] "https://api.github.com/copilot_internal/v2/token": 403 Forbidden]

FetchError: [GET] "https://api.github.com/copilot_internal/v2/token": 403 Forbidden

Bun v1.2.2 (Windows x64)
error: script "start" exited with code 1
PS D:\copilot-api> bun run start --port 8080 --emulate-streaming
$ NODE_ENV=production bun run ./src/main.ts --port "8080" --emulate-streaming
◐ Initializing App directory...                                                                             9:51:03 AM
✔ App directory initialized                                                                                9:51:03 AM
◐ Initializing GitHub authentication...                                                                     9:51:03 AM
ℹ Logged in as "XXXX"                                                                       9:51:04 AM
✔ GitHub authentication initialized                                                                        9:51:04 AM
◐ Initializing Copilot token...                                                                             9:51:04 AM
✔ Copilot token initialized                                                                                9:51:04 AM
◐ Initializing Model information...                                                                         9:51:04 AM
ℹ Available models:                                                                                        9:51:05 AM
- gpt-3.5-turbo
- gpt-3.5-turbo-0613
- gpt-4
- gpt-4-0613
- gpt-4o
- gpt-4o-2024-05-13
- gpt-4-o-preview
- gpt-4o-2024-08-06
- text-embedding-ada-002
- text-embedding-3-small
- text-embedding-3-small-inference
- gpt-4o-mini
- gpt-4o-mini-2024-07-18
- o3-mini-paygo
- claude-3.5-sonnet
✔ Model information initialized                                                                            9:51:05 AM
✔ Server started at http://localhost:8080                                                                  9:51:05 AM
<-- GET /
--> GET / 200 1ms
<-- GET /favicon.ico
--> GET /favicon.ico 404 1ms
<-- GET /v1/models
--> GET /v1/models 404 1ms
<-- GET /v1/models
--> GET /v1/models 404 0ms
<-- POST /v1/chat/completions
--> POST /v1/chat/completions 404 0ms
<-- GET /v1/models
--> GET /v1/models 404 0ms
<-- GET /v1/models
--> GET /v1/models 404 1ms
<-- POST /chat/completions
ℹ Received request: { model: 'gpt-4o',                                                                    10:01:34 AM
  messages:
   [ { role: 'system',
       content:
        'You are Cline, a highly skilled software engineer with extensive knowledge in many programming la...' },
     { role: 'user', content: [Array] } ],
  temperature: 0,
  stream: true,
  stream_options: { include_usage: true } }
[10:01:37 AM] ℹ Response from Copilot: {"choices":[{"content_filter_results":{"hate":{"filtered":false,"severity":"safe"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions