fix(oauth): auto-refresh expired tokens in fetchOAuthUsage

Replace direct token decryption with getValidAccessToken call to
enable automatic token expiration check and refresh. This fixes
authentication_error when fetching OAuth usage data with expired
access tokens.
This commit is contained in:
iaineng
2025-10-01 11:58:16 +08:00
parent e88f07ca92
commit 782e912a0d

View File

@@ -1607,12 +1607,9 @@ class ClaudeAccountService {
throw new Error('Account not found')
}
// 如果没有提供 accessToken使用账号存储的 token
// 如果没有提供 accessToken使用 getValidAccessToken 自动检查过期并刷新
if (!accessToken) {
accessToken = this._decryptSensitiveData(accountData.accessToken)
if (!accessToken) {
throw new Error('No access token available')
}
accessToken = await this.getValidAccessToken(accountId)
}
// 如果没有提供 agent创建代理