kom*_*mal 5 azure-active-directory azure-ad-graph-api azure-ad-msal angular
在使用 MSAL-Angular 并为 Azure Active Directory 图形 api( https://graph.windows.net/ )请求 access_token 时,它提供带有 Microsoft 图形 api( https://graph.microsoft.com ) aud 的令牌
我需要调用 azure 活动目录图形 api,因为 Microsoft 图形 api 处于测试版。现在,当我使用 msalService 获取 Azure Active Directory 图形 api 的 access_token 时,它会提供带有 microsoft 图形 api aud 的令牌。当我尝试使用该令牌时,它给出了“您的访问令牌已过期”的错误。请在提交请求之前更新它。即使令牌具有有效时间。
我使用下面的打字稿代码来生成 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));
});
});
});
Run Code Online (Sandbox Code Playgroud)
}
| 归档时间: |
|
| 查看次数: |
4603 次 |
| 最近记录: |