簡體   English   中英

Microsoft Graph API返回“訪問令牌驗證錯誤”

[英]Microsoft Graph API Returning “Access Token Validation Error”

我已經在Microsoft注冊了Angular2應用,該應用完全是客戶端來訪問Graph API。 我啟用了“隱式授權流”,並且在登錄和首次授權后能夠成功獲取JWT。

URL片段甚至說這是一個承載令牌,如下所示:

http://localhost:4200/loginRedirect#access_token={JWT_TOKEN_HERE}&token_type=Bearer&expires_in=3600&session_state={state_guid}

我的身份驗證重定向如下所示:

window.location.href = "https://login.microsoftonline.com/common/oauth2/authorize?resource=" + encodeURIComponent('https://graph.windows.net') + "&response_type=token&client_id=" + this._config.clientId + "&redirect_uri=" + encodeURIComponent(this._config.redirectUri);

盡管在我的Graph API請求的標頭中包含獲取的JWT:

Authorization: Bearer {JWT_TOKEN_HERE}

我收到401: Access Token Validation Error

我以為,自從我成功檢索到該令牌后,它告訴我是Bearer ,它可以工作,但事實並非如此。

有人知道我在做什么錯嗎?

資源URI錯誤。 Azure AD Graph API是https://graph.windows.net

Microsoft Graph API資源URI是https://graph.microsoft.com/ ,請嘗試一下。

Azure AD Graph API是AAD的API,而Microsoft Graph API也涵蓋Office 365服務。 令人困惑的命名。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM