Skip to content

Commit c925dd1

Browse files
committed
fix: use GitHub Copilot CLI App client ID and add API version header to token exchange
1 parent 8addae6 commit c925dd1

6 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/server/core/domain/entities/provider-registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export const PROVIDER_REGISTRY: Readonly<Record<string, ProviderDefinition>> = {
155155
name: 'GitHub Copilot',
156156
oauth: {
157157
callbackMode: 'device',
158-
clientId: 'Ov23li8tweQw6odWQebz',
158+
clientId: 'Iv1.b507a08c87ecfe98',
159159
modes: [{authUrl: 'https://github.com/login/device', id: 'default', label: 'Sign in with GitHub'}],
160160
redirectUri: '',
161161
scopes: 'read:user',

src/server/infra/provider-oauth/device-flow.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import axios, {isAxiosError} from 'axios'
44
import {
55
COPILOT_TOKEN_URL,
66
DEVICE_FLOW_INTERVAL_BUFFER,
7+
GITHUB_API_VERSION,
78
GITHUB_DEVICE_CODE_URL,
89
GITHUB_OAUTH_TOKEN_URL,
910
} from '../../../shared/constants/copilot.js'
@@ -153,6 +154,7 @@ export async function exchangeForCopilotToken(githubToken: string): Promise<Copi
153154
headers: {
154155
Accept: 'application/json',
155156
Authorization: `token ${githubToken}`,
157+
'X-GitHub-Api-Version': GITHUB_API_VERSION,
156158
},
157159
})
158160
} catch (error) {

src/shared/constants/copilot.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/** GitHub OAuth App client ID (public — used for device flow, no client secret). */
2-
export const COPILOT_GITHUB_CLIENT_ID = 'Ov23li8tweQw6odWQebz'
1+
/** GitHub Copilot CLI App client ID (public — used for device flow, no client secret). */
2+
export const COPILOT_GITHUB_CLIENT_ID = 'Iv1.b507a08c87ecfe98'
33

44
/** GitHub device code request endpoint. */
55
export const GITHUB_DEVICE_CODE_URL = 'https://github.com/login/device/code'
@@ -28,6 +28,8 @@ export const DEVICE_FLOW_INTERVAL_BUFFER = 3
2828
/** Copilot models endpoint for listing available models. */
2929
export const COPILOT_MODELS_ENDPOINT = '/models'
3030

31+
export const GITHUB_API_VERSION = '2025-04-01'
32+
3133
/** Editor version header value sent with Copilot API requests. */
3234
export const COPILOT_EDITOR_VERSION = 'vscode/1.99.0'
3335

test/unit/core/domain/entities/provider-registry.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe('Provider Registry', () => {
148148

149149
it('should have correct oauth clientId', () => {
150150
const copilot = getProviderById('github-copilot')
151-
expect(copilot?.oauth?.clientId).to.equal('Ov23li8tweQw6odWQebz')
151+
expect(copilot?.oauth?.clientId).to.equal('Iv1.b507a08c87ecfe98')
152152
})
153153

154154
it('should have oauth modes with GitHub device auth URL', () => {

test/unit/infra/provider-oauth/device-flow.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ describe('device-flow', () => {
270270
.get(COPILOT_TOKEN_PATH)
271271
.matchHeader('Authorization', 'token gho_my_token')
272272
.matchHeader('Accept', 'application/json')
273+
.matchHeader('X-GitHub-Api-Version', '2025-04-01')
273274
.reply(200, {
274275
expires_at: expiresAt,
275276
token: 'tid=some_token',

test/unit/infra/transport/handlers/provider-handler.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ describe('ProviderHandler', () => {
952952

953953
expect(requestDeviceCodeStub.calledOnce).to.be.true
954954
const params = requestDeviceCodeStub.firstCall.args[0]
955-
expect(params.clientId).to.equal('Ov23li8tweQw6odWQebz')
955+
expect(params.clientId).to.equal('Iv1.b507a08c87ecfe98')
956956
expect(params.scope).to.equal('read:user')
957957
})
958958
})
@@ -1086,7 +1086,7 @@ describe('ProviderHandler', () => {
10861086

10871087
const params = pollForAccessTokenStub.firstCall.args[0]
10881088
expect(params.deviceCode).to.equal('test-device-code')
1089-
expect(params.clientId).to.equal('Ov23li8tweQw6odWQebz')
1089+
expect(params.clientId).to.equal('Iv1.b507a08c87ecfe98')
10901090
expect(params.expiresIn).to.equal(900)
10911091
expect(params.interval).to.equal(5)
10921092
})

0 commit comments

Comments
 (0)