(спасибо идет к stillatmylinux)
К вашему сведению: вот мое рабочее угловое 7 решение (упрощено для удобства чтения):
import { MsalService, BroadcastService } from '@azure/msal-angular';
import { Client } from '@microsoft/microsoft-graph-client';
private subscription: Subscription;
private graphClient: Client;
private memberRoles: any[];
constructor(
readonly auth: MsalService,
readonly broadcast: BroadcastService
) {
// Initialize Microsoft Graph client
this.graphClient = Client.init({
authProvider: async (done) => {
let token = await this.auth.acquireTokenSilent(["User.Read", "Directory.Read.All"])
.catch((reason) => {
done(reason, null);
});
if (token) {
done(null, token);
} else {
done("Could not get an access token", null);
}
}
});
this.subscription = broadcast.subscribe("msal:loginSuccess",
() => {
//Get associated member roles
this.graphClient.api('/me/memberOf').get()
.then((response) => {
this.memberRoles = response.value;
}, (error) => {
console.log('getMemberRoles() - error');
});
});
}