【问题标题】:Token for graph.microsoft.com from adal.js来自 adal.js 的 graph.microsoft.com 的令牌
【发布时间】:2018-06-05 22:50:52
【问题描述】:

我已经阅读了一些堆栈问题。

我有一个简单的 Web 应用程序,身份验证运行良好。我只是使用 ADAL 及其工作。

var endpoints = {
      "https://graph.microsoft.com": "https://graph.microsoft.com",
      'https://login.microsoftonline.com/':'https://login.microsoftonline.com/'
}

window.config = {
      tenant: 'xxx.com',
      clientId: guid,
      endpoints: endpoints,
      cacheLocation: 'localStorage',
};

我登录

authContext.login();

我得到一个令牌

authContext.acquireToken(config.clientId,
      function (error, token) {
            if (error) console.log(error);
            localStorage.setItem('token', token);
      }
);

一切正常,我想我需要https://graph.microsoft.com 的另一个令牌,所以我这样做了

authContext.acquireToken('https://graph.microsoft.com',
      function (error, token) {
            console.log('callback token graph', token, error);            
            if (error) console.log(error);
            localStorage.setItem('gtoken', token);
      }

这永远不会打回电话。我已经尝试删除对acquireToken 的第一次调用

或者是我的第一个令牌用于 Microsoft Graph 调用(这是我认为一开始应该如何工作,我有点绕圈子:))

【问题讨论】:

    标签: javascript microsoft-graph-api adal


    【解决方案1】:

    我必须按如下方式编辑清单

    "oauth2AllowImplicitFlow": true,
    

    并还原我添加的大量垃圾代码:)

    由于其他原因,错误被吞下。 ADAL 要求在页面正常工作之前呈现该页面。我对事情发生的顺序有一些问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-16
      • 2019-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多