diff --git a/lib/sdk/oauth2-flows/AuthCodeAbstract.ts b/lib/sdk/oauth2-flows/AuthCodeAbstract.ts index 1f6758b..8359f6b 100644 --- a/lib/sdk/oauth2-flows/AuthCodeAbstract.ts +++ b/lib/sdk/oauth2-flows/AuthCodeAbstract.ts @@ -247,10 +247,6 @@ export abstract class AuthCodeAbstract { scope: this.config.scope ?? AuthCodeAbstract.DEFAULT_TOKEN_SCOPES, }; - if (this.config.audience) { - searchParamsObject.audience = this.config.audience; - } - if (options.start_page) { searchParamsObject.start_page = options.start_page; } @@ -275,6 +271,15 @@ export abstract class AuthCodeAbstract { for (const key in searchParamsObject) searchParams.append(key, searchParamsObject[key]); + if (this.config.audience) { + const audienceArray = Array.isArray(this.config.audience) ? this.config.audience : [this.config.audience]; + + audienceArray + .forEach((aud) => { + searchParams.append('audience', aud); + }); + } + return searchParams; } } diff --git a/lib/sdk/oauth2-flows/ClientCredentials.ts b/lib/sdk/oauth2-flows/ClientCredentials.ts index 44f2f2d..7368f40 100644 --- a/lib/sdk/oauth2-flows/ClientCredentials.ts +++ b/lib/sdk/oauth2-flows/ClientCredentials.ts @@ -115,7 +115,12 @@ export class ClientCredentials { }); if (this.config.audience) { - searchParams.append('audience', this.config.audience); + const audienceArray = Array.isArray(this.config.audience) ? this.config.audience : [this.config.audience]; + + audienceArray + .forEach((aud) => { + searchParams.append('audience', aud); + }); } return new URLSearchParams(searchParams); diff --git a/lib/sdk/oauth2-flows/types.ts b/lib/sdk/oauth2-flows/types.ts index aec039f..4e77b04 100644 --- a/lib/sdk/oauth2-flows/types.ts +++ b/lib/sdk/oauth2-flows/types.ts @@ -32,7 +32,7 @@ export interface OAuth2FlowOptions { clientId: string; logoutRedirectURL: string; authDomain: string; - audience?: string; + audience?: string | string[]; scope?: string; }