fix(opencode): use generic reauthentication guidance
This commit is contained in:
parent
075b02a15e
commit
5ee0c123ec
2 changed files with 6 additions and 6 deletions
|
|
@ -151,7 +151,7 @@ async function refreshAccessToken(refreshToken: string, issuer = ISSUER): Promis
|
||||||
code === "refresh_token_invalidated"
|
code === "refresh_token_invalidated"
|
||||||
) {
|
) {
|
||||||
throw new ProviderError.AuthenticationError(
|
throw new ProviderError.AuthenticationError(
|
||||||
"Your ChatGPT login could not be refreshed. Run `opencode auth login` to sign in again.",
|
"Your ChatGPT login could not be refreshed. Please sign in again.",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
throw new Error(`Token refresh failed: ${response.status}`)
|
throw new Error(`Token refresh failed: ${response.status}`)
|
||||||
|
|
@ -526,10 +526,10 @@ export async function CodexAuthPlugin(input: PluginInput, options: CodexAuthPlug
|
||||||
...init,
|
...init,
|
||||||
headers,
|
headers,
|
||||||
}
|
}
|
||||||
const request = () =>
|
const request = () => {
|
||||||
websocketFetch && parsed.pathname.endsWith("/responses")
|
if (websocketFetch && parsed.pathname.endsWith("/responses")) return websocketFetch(url, requestInit)
|
||||||
? websocketFetch(url, requestInit)
|
return fetch(url, OpenAIWebSocketPool.withoutInternalHeaders(requestInit))
|
||||||
: fetch(url, OpenAIWebSocketPool.withoutInternalHeaders(requestInit))
|
}
|
||||||
const response = await request()
|
const response = await request()
|
||||||
if (response.status !== 401) return response
|
if (response.status !== 401) return response
|
||||||
await response.body?.cancel()
|
await response.body?.cancel()
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,7 @@ describe("plugin.codex", () => {
|
||||||
const error = await loaded.fetch!("https://api.openai.com/v1/responses").catch((error: unknown) => error)
|
const error = await loaded.fetch!("https://api.openai.com/v1/responses").catch((error: unknown) => error)
|
||||||
|
|
||||||
expect(error).toBeInstanceOf(ProviderError.AuthenticationError)
|
expect(error).toBeInstanceOf(ProviderError.AuthenticationError)
|
||||||
expect(error.message).toContain("opencode auth login")
|
expect(error.message).toBe("Your ChatGPT login could not be refreshed. Please sign in again.")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue