Skip to content

Commit 4936d97

Browse files
#1441 - Fix for getContext without callback (#1674)
Co-authored-by: Sébastien Levert <[email protected]>
1 parent 26f8d31 commit 4936d97

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/providers/mgt-teams-msal2-provider/src/TeamsMsal2Provider.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ export class TeamsMsal2Provider extends Msal2Provider {
424424
if (!this.teamsContext && TeamsHelper.microsoftTeamsLib) {
425425
const teams = TeamsHelper.microsoftTeamsLib;
426426
teams.initialize();
427-
this.teamsContext = await teams.getContext();
427+
this.teamsContext = await this.getTeamsContext();
428428
}
429429

430430
const scopes = options ? options.scopes || this.scopes : this.scopes;
@@ -560,6 +560,20 @@ export class TeamsMsal2Provider extends Msal2Provider {
560560
});
561561
}
562562

563+
/**
564+
* Retrieves the Teams context
565+
*/
566+
private async getTeamsContext() {
567+
return new Promise(resolve => {
568+
const teams = TeamsHelper.microsoftTeamsLib;
569+
teams.initialize();
570+
teams.getContext(context => {
571+
resolve(context);
572+
return;
573+
});
574+
});
575+
}
576+
563577
private unhandledFetchError(err: any) {
564578
console.error(`There was an error during the server side token exchange: ${err}`);
565579
}

0 commit comments

Comments
 (0)