【问题标题】:renewal token is not working in adal.js v1.0.14更新令牌在 adal.js v1.0.14 中不起作用
【发布时间】:2018-07-31 16:54:33
【问题描述】:

我使用的是 adal.js 1.0.14,下面是我的登录信息

 var authenticationContext = new AuthenticationContext(config);
    if (!config.popUp) {
        if (authenticationContext.isCallback(window.location.hash)) {
            authenticationContext.handleWindowCallback();
        }
    }
    var user = authenticationContext.getCachedUser();
    sessionStorage.setItem("adal:Tenant","@CommonMethods.GetAppConfigValue("ida:TenantId")")
    if (!user) {
        authenticationContext.login();
    }

以下是我的续订代码

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);
            }
        });

但我得到“需要用户登录”。无法理解这是怎么回事。

【问题讨论】:

    标签: angularjs azure-active-directory adal


    【解决方案1】:

    我遇到了问题,问题是,我使用以下配置设置进行身份验证

    var config = {
    tenant: window.sessionStorage.getItem('adal:Tenant'),
    clientId: window.sessionStorage.getItem('adal.token.keys'),
    redirectUri: baseURL,
    popUp: false,
    postLogoutRedirectUri: baseURL,
    expireOffsetSeconds: 3540
    

    }

    在上面的代码中,ClientId 包含'|',因此无法获取token和用户信息。我更新了我的配置设置,

    var config = {
    tenant: window.sessionStorage.getItem('adal:Tenant'),
    clientId: window.sessionStorage.getItem('adal.token.keys').replace('|', ''),
    redirectUri: baseURL,
    popUp: false,
    postLogoutRedirectUri: baseURL,
    expireOffsetSeconds: 3540
    

    }

    而且它有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-15
      • 2017-07-18
      • 2019-02-02
      • 1970-01-01
      • 2018-03-30
      • 2021-08-24
      • 1970-01-01
      • 2020-10-11
      相关资源
      最近更新 更多