Angular中的Adal.js令牌刷新问题 [英] Adal.js Token refresh issue in Angular
问题描述
刷新令牌未如我在adal.js(@types-1.0.8)中所预期的那样工作,当用户在屏幕上闲置了最后15分钟(因为我在旧令牌到期前15分钟之前刷新令牌),并且执行该操作后,我的服务呼叫将失败.因为它会在标头中获取旧令牌(过期),但是令牌刷新也将在此之后进行.我如何在angularJS和adal库中处理此问题?我使用以下代码获取刷新令牌
Refresh token is not working as I expected in adal.js(@types - 1.0.8), When user is idle on screen for last 15 minutes (because I refresh token before 15 minutes of expiry of old token), and after that perform action, then my service call fail. because it gets old token(which expire) in header, but token refresh is also done after that. how I can handle this in angularJS and adal library? I used below code to get refresh token
this.authenticationContext.getCachedUser();
this.authenticationContext.acquireToken(config.clientId, function (errorDesc, token) {
if (errorDesc) {
console.log("ErrorDesc", errorDesc);
}
if (token) {
console.log("calling the Web API with the access token", token);
}
});
成角度.
推荐答案
Azure身份验证令牌每1小时失效一次.您需要在令牌过期之前刷新令牌.为此,在ADAL.js库上有很多角度包装器.请在下面的链接中查看我的答案以获取想法.
Azure authentication token expires every 1 hour. you need to refresh the token before the token get expired. there are many angular wrappers over ADAL.js library for the purpose. See my answer in the below link to get an idea.
Adal Angular 4-Refresh Token not按预期工作
这篇关于Angular中的Adal.js令牌刷新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!