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

我想我只有一個刷新標記,我在我的問題中添加了。 –

相關問題