fix(oauth): fix OAuth token authentication flow for existing installations

This commit is contained in:
2025-07-24 12:28:50 +00:00
parent 76c6b95f3d
commit 9011390dc4
5 changed files with 60 additions and 31 deletions

View File

@@ -64,10 +64,10 @@ export class BunqAccount {
const errorMessages = error.errors.map(e => e.error_description).join(' ');
if (errorMessages.includes('Superfluous authentication') ||
errorMessages.includes('Authentication token already has a user session')) {
console.log('OAuth token already has an active session, attempting to reuse...');
// Try to use the token directly without creating new session
await this.apiContext.initWithExistingSession();
// Cache the context with existing session
console.log('OAuth token already has installation/device, attempting to create new session...');
// Try to create a new session with existing installation/device
await this.apiContext.initWithExistingInstallation();
// Cache the context with new session
BunqAccount.oauthSessionCache.set(cacheKey, this.apiContext);
} else {
throw error;