fix(oauth): correct OAuth implementation to match bunq documentation
This commit is contained in:
@@ -44,15 +44,6 @@ export class BunqApiContext {
|
||||
* Initialize the API context (installation, device, session)
|
||||
*/
|
||||
public async init(): Promise<void> {
|
||||
// If using OAuth token, skip session creation
|
||||
if (this.options.isOAuthToken) {
|
||||
// OAuth tokens already have an associated session
|
||||
this.context.sessionToken = this.options.apiKey;
|
||||
this.session = new BunqSession(this.crypto, this.context);
|
||||
this.session.setOAuthMode(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to load existing context
|
||||
const existingContext = await this.loadContext();
|
||||
|
||||
@@ -78,6 +69,11 @@ export class BunqApiContext {
|
||||
this.options.deviceDescription,
|
||||
this.options.permittedIps || []
|
||||
);
|
||||
|
||||
// Set OAuth mode if applicable (for session expiry handling)
|
||||
if (this.options.isOAuthToken) {
|
||||
this.session.setOAuthMode(true);
|
||||
}
|
||||
|
||||
// Save context
|
||||
await this.saveContext();
|
||||
@@ -135,11 +131,6 @@ export class BunqApiContext {
|
||||
* Refresh session if needed
|
||||
*/
|
||||
public async ensureValidSession(): Promise<void> {
|
||||
// OAuth tokens don't need session refresh
|
||||
if (this.options.isOAuthToken) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.session.refreshSession();
|
||||
await this.saveContext();
|
||||
}
|
||||
|
Reference in New Issue
Block a user