fix: Fixing token refresh logic for oca on startup (#7209)

* fix: Fixing token refresh logic for oca on startup

* fix: Fixing token refresh logic for oca on startup
This commit is contained in:
nihar-oracle authored and GitHub committed 2025-11-05 09:14:42 -08:00
1 parent 68ffe20b7d
commit 08ca115c66
2 files changed
+19 -1

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": patch
---
Fixing the logic for Oca Token Refresh
@@ -85,9 +85,14 @@ export class OcaAuthProvider {
}
async retrieveOcaAuthState(controller: Controller): Promise<OcaAuthState | null> {
// First Check the existing access token
const existingAuthState = await this.getExistingAuthState(controller)
if (existingAuthState) {
return existingAuthState
}
// Otherwise, try to refresh using the refresh token
const userRefreshToken = controller.stateManager.getSecretKey("ocaRefreshToken")
if (!userRefreshToken) {
// Try getting the
console.error("No stored authentication credential found.")
return null
}
@@ -109,6 +114,14 @@ export class OcaAuthProvider {
...getAxiosSettings(),
})
const accessToken = tokenResponse.data.access_token
const refreshToken = tokenResponse.data.refresh_token
if (refreshToken) {
controller.stateManager.setSecret("ocaRefreshToken", refreshToken)
controller.stateManager.setSecret("ocaApiKey", accessToken)
} else {
console.warn("No refresh token received during OCA token refresh.")
throw new OcaRefreshError("No refresh token received during OCA token refresh.")
}
const userInfo: OcaUserInfo = await this.getUserAccountInfo(accessToken)
return { user: userInfo, apiKey: accessToken }
} catch (err: unknown) {