AADSTS50058:已发送静默登录请求,但未在

时间:2017-08-03 19:00:42

标签: javascript azure-active-directory microsoft-graph hello.js

我正在使用hello.js登录Microsoft Graph。

首先我按

初始化
hello.init({
    msft: {
      id: myAppId,
      oauth: {
        version: 2,
        auth: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize'
      },
      scope_delim: ' ',
      form: false
    },
  },
  { redirect_uri: window.location.href }
);

然后我在我的应用中成功登录

hello('msft').login({ scope: 'User.Read' })

登录后,这是hello.js在localStorage中保存的内容。

{
  "msft": {
  "access_token":"aLongToken",
    "token_type":"Bearer",
    "expires_in":3599,
    "scope":"basic,User.Read",
    "state":"",
    "session_state":"f034f785-f8d0-4cec-aab4-88559c9d93dd",
    "client_id":"a91e6907-2b6e-4793-848d-633e960e809d",
    "network":"msft",
    "display":"popup",
    "redirect_uri":"http://localhost:3006/login",
    "expires":1501800737.361
  }
}

然而,当我尝试刷新access_token

hello('msft').login({
  display: 'none',
  response_type: 'id_token token',
  response_mode: 'fragment',
  nonce: 'my-app',
  prompt: 'none',
  scope: 'User.Read',
  login_hint: 'Rose.Bukater@company.com',
  domain_hint: 'organizations'
})

我收到了错误

  

AADSTS50058:已发送静默登录请求,但未签署任何用户   用于表示用户会话的cookie未被发送   对Azure AD的请求。如果用户使用Internet,则会发生这种情况   Explorer或Edge以及发送静默登录请求的Web应用程序   与Azure AD端点位于不同的IE安全区域中   (login.microsoftonline.com)。

我正在使用Chrome。

在GitHub上找到this issue。但仍然没有弄清楚如何正确刷新。

更新:

https://apps.dev.microsoft.com禁用允许隐含流量后,现在我甚至无法登录。所以这不是正确的解决方案。 hello.js在localStorage中保存了这个错误:

{
  "msft": {
    "error": {
      "code":"unsupported_response_type",
      "message":"AADSTS70005: response_type 'token' is not enabled for the application\r\nTrace ID: 1dc20dd0-cab3-41b5-9849-2a7e35d60700\r\nCorrelation ID: caacce8f-6763-405d-a840-70c24d5306d4\r\nTimestamp: 2017-08-04 21:56:42Z"
    },
    "error_description":"AADSTS70005: response_type 'token' is not enabled for the application\r\nTrace ID: 1dc20dd0-cab3-41b5-9849-2a7e35d60700\r\nCorrelation ID: caacce8f-6763-405d-a840-70c24d5306d4\r\nTimestamp: 2017-08-04 21:56:42Z",
    "state":"",
    "client_id":"a91e6907-2b6e-4793-848d-633e960e809d",
    "network":"msft",
    "display":"popup",
    "redirect_uri":"http://localhost:3006/login",
    "scope":"basic,User.Read"
  }
}

2 个答案:

答案 0 :(得分:1)

当login.microsoftonline.com当前连接的用户的cookie已过期时,会发生这种情况。我们处理它的方式是将用户重定向到登录页面,当前页面为redirecturi参数。

答案 1 :(得分:1)

我发现了这个问题。我在问题中的代码是完全正确的。造成这个问题的原因是因为在我们公司,每个人都有两封电子邮件:

  • 一个是全名电子邮件 Rose.Bukater@company.com
  • 一个是别名电子邮件 rosebuk@company.com ,这是属性setTimeout

对于下面的setTimeout,它必须是别名电子邮件。

userPrincipalName
相关问题