@@ -40,6 +40,7 @@ import {
4040import {
4141 getApiKey as fetchApiKey ,
4242 maybeRedeemCredits ,
43+ fetchGithubCopilotApiKey ,
4344} from "./utils/get-api-key" ;
4445import { createInputItem } from "./utils/input-utils" ;
4546import { initLogger } from "./utils/logger/log" ;
@@ -328,7 +329,11 @@ try {
328329}
329330
330331if ( cli . flags . login ) {
331- apiKey = await fetchApiKey ( client . issuer , client . client_id ) ;
332+ if ( provider . toLowerCase ( ) === "githubcopilot" ) {
333+ apiKey = await fetchGithubCopilotApiKey ( ) ;
334+ } else {
335+ apiKey = await fetchApiKey ( client . issuer , client . client_id ) ;
336+ }
332337 try {
333338 const home = os . homedir ( ) ;
334339 const authDir = path . join ( home , ".codex" ) ;
@@ -341,7 +346,11 @@ if (cli.flags.login) {
341346 /* ignore */
342347 }
343348} else if ( ! apiKey ) {
344- apiKey = await fetchApiKey ( client . issuer , client . client_id ) ;
349+ if ( provider . toLowerCase ( ) === "githubcopilot" ) {
350+ apiKey = await fetchGithubCopilotApiKey ( ) ;
351+ } else {
352+ apiKey = await fetchApiKey ( client . issuer , client . client_id ) ;
353+ }
345354}
346355// Ensure the API key is available as an environment variable for legacy code
347356process . env [ "OPENAI_API_KEY" ] = apiKey ;
0 commit comments