Skip to content

Commit 5420dc3

Browse files
authored
Merge pull request #2 from Back-to-code/F2F-1531-scraper-protocol-authenticatie-omzetten
Scraper-protocol authenticatie omzetten van RT-CV credentials naar App API keys
2 parents 68d2f0d + 35cf70f commit 5420dc3

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

lib/app_auth.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface AppAuth {
1919
export class AppTokenManager {
2020
private token: string | null = null
2121
private tokenExpiresAt: number = 0
22+
private pending: Promise<string> | null = null
2223

2324
constructor(private auth: AppAuth) {}
2425

@@ -27,7 +28,14 @@ export class AppTokenManager {
2728
return this.token
2829
}
2930

30-
return await this.authenticate()
31+
if (this.pending) {
32+
return await this.pending
33+
}
34+
35+
this.pending = this.authenticate().finally(() => {
36+
this.pending = null
37+
})
38+
return await this.pending
3139
}
3240

3341
private async authenticate(): Promise<string> {

0 commit comments

Comments
 (0)