Merge pull request #3642 from infinityf4p/fix/openai-subscription-expiry-save

fix(openai): persist subscription expiration from OAuth
This commit is contained in:
Wesley Liddick
2026-07-02 17:31:58 +08:00
committed by GitHub
2 changed files with 18 additions and 0 deletions
@@ -59,6 +59,20 @@ describe('useOpenAIOAuth.buildCredentials', () => {
expect(creds.access_token).toBe('at')
expect(creds.refresh_token).toBe('rt')
})
it('should keep ChatGPT subscription expiration from token response', () => {
const oauth = useOpenAIOAuth()
const creds = oauth.buildCredentials({
access_token: 'at',
refresh_token: 'rt',
expires_at: 1700000000,
plan_type: 'team',
subscription_expires_at: '2026-07-20T19:22:48+00:00'
})
expect(creds.plan_type).toBe('team')
expect(creds.subscription_expires_at).toBe('2026-07-20T19:22:48+00:00')
})
})
describe('useOpenAIOAuth.exchangeAuthCode', () => {
@@ -16,6 +16,7 @@ export interface OpenAITokenInfo {
email?: string
name?: string
plan_type?: string
subscription_expires_at?: string
privacy_mode?: string
// OpenAI specific IDs (extracted from ID Token)
chatgpt_account_id?: string
@@ -197,6 +198,9 @@ export function useOpenAIOAuth() {
if (tokenInfo.plan_type) {
creds.plan_type = tokenInfo.plan_type
}
if (tokenInfo.subscription_expires_at) {
creds.subscription_expires_at = tokenInfo.subscription_expires_at
}
if (tokenInfo.client_id) {
creds.client_id = tokenInfo.client_id
}