While using MSAL-Angular and requesting an access_token for Azure Active Directory graph api(https://graph.windows.net/), it gives token with aud of Microsoft graph api(https://graph.microsoft.com)
i need to call azure active directory graph api because Microsoft graph api is in beta version. now when i use msalService to get access_token for Azure Active Directory graph api it gives token with aud of microsoft graph api. when i tried to use that token it gives error of 'Your access token has expired. Please renew it before submitting the request.' even though token is with valid time.
I am using below typescript code to generate the access_token public async getAccessToken(endpointUri: string): Promise {
this.accessToken = '';
const scopes = this.msalService.getScopesForEndpoint(endpointUri);
return new Promise<boolean>((resolve, reject) => {
this.msalService.acquireTokenSilent(scopes)
.then(accessToken => {
this.accessToken = accessToken;
resolve(true);
// tslint:disable-next-line: promise-function-async
}).catch(() => {
return this.msalService.acquireTokenPopup(scopes)
.then(token => {
this.accessToken = token;
resolve(true);
})
.catch((error) => {
reject(new Error(error));
});
});
});
}