我正在使用 Javascript(不带 Angular)向我的单页 Web 应用程序添加 AAD 身份验证。初始登录工作正常,但一个小时后,令牌过期,我无法使用acquireToken 更新它。当我仍然使用我的客户端 ID 登录时,我尝试调用 AcquireToken 并且它工作正常,但是在令牌过期后,我无法更新它。它因“由于超时而导致令牌更新操作失败”而失败。
令牌过期后,我运行了这个:
// ADALContext created from calling new AuthenticationContext
// passed in same clientID to acquire token as to create ADALContext
ADALContext.acquireToken(clientID, function (error, token) {console.log(error, token)})
Run Code Online (Sandbox Code Playgroud)
我在 AAD 中启用了 oauth2AllowImplicitFlow。
"keyCredentials": [],
"knownClientApplications": [],
"logoutUrl": null,
"oauth2AllowImplicitFlow": true,
"oauth2AllowUrlPathMatching": true,
Run Code Online (Sandbox Code Playgroud)
不知道我错过了什么步骤。谢谢!
编辑:令牌过期后,如果我运行acquireToken(clientID,func),我会收到“需要用户登录”。但是,如果我调用 getCachedUser,我会返回一个用户,然后调用acquireToken 返回超时错误。