0

我使用hello.js在Microsoft Graph中签。AADSTS50058:一个无声的登录请求被发送,但没有用户登录,

首先我通过

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: '[email protected]', 
    domain_hint: 'organizations' 
}) 

我得到了错误

AADSTS50058:一个无声的登录请求被发送,但没有用户登录, 用来表示用户会话的cookies在 请求没有被发送到Azure AD。这可以,如果用户使用因特网 Explorer或边缘发生,该网络应用程序发送所述静默登录请求 是在不同的IE安全区域比天青AD端点 (login.microsoftonline.com)。

我使用Chrome。

在GitHub实测值this issue。但仍然没有弄清楚如何正确刷新。


UPDATE:

禁用后在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" 
    } 
} 

回答

0

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

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

hello('msft').login({ 
    display: 'none', 
    response_type: 'id_token token', 
    response_mode: 'fragment', 
    nonce: 'my-app', 
    prompt: 'none', 
    scope: 'User.Read', 
    login_hint: '[email protected]', // <- has to be [email protected] 
    domain_hint: 'organizations' 
}) 
+0

你知道为什么以及如何知道哪一个是使用?假设您的用户对象包含两个电子邮件地址 - 哪个属性是正确的? –

+0

@mikenelson它是'userPrincipalName' –

0

在当前连接的login.microsoftonline.com的用户的Cookie已经过期它发生。我们处理它的方式是,我们重定向用户使用当前页面登录页面作为redirecturi参数。

+0

hello.js在localstorage中保存了令牌。我没有看到它使用cookies。并且实际上测试刷新令牌。我在登录后仅用了20秒就完成了,所以我认为任何事情都没有过期。也许别的什么原因呢? –

+0

如果你看看你得到的第一个令牌,它是否包含一个刷新令牌?你是否利用明确的格兰特或隐式流程? – baywet

+0

我想我只有一个刷新标记,我在我的问题中添加了。 –

相关问题