久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Azure AD API 請求 401 未經授權

Azure AD API request 401 Unauthorized(Azure AD API 請求 401 未經授權)
本文介紹了Azure AD API 請求 401 未經授權的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我在啟用了 Azure AD 身份驗證的 Azure 網站上運行了一個標準 Web API,當在瀏覽器中瀏覽 API 時,我能夠通過瀏覽器登錄并獲得對 API 的訪問權限.

I have a standard Web API running on an Azure website with Azure AD authentication enabled, when browsing to the API in a browser I am able to login via the browser and gain access to the API.

然而,WPF 桌面應用程序在提交請求時收到未經授權響應:

The WPF desktop application however is receiving an Unauthorized response when submitting the request:

var authContext = new AuthenticationContext(authority, new FileCache());
var accessToken = await authContext.AcquireTokenAsync(apiResourceid, clientId, redirectUri,
                    new PlatformParameters(PromptBehavior.Auto));
// accessToken is valid

var apiUrl = "https://example.azurewebsites.net/api/list";
var request = new HttpRequestMessage(HttpMethod.Get, apiUrl);
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.AccessToken);
var response = await httpClient.SendAsync(request);

認證成功,調試時可以看到用戶信息.

The authentication is successfull and I can see the User info when debugging.

我無權訪問 Azure 帳戶,但我確信 Service AD 應用程序配置正確,允許訪問客戶端 AD 應用程序,就像在備用帳戶(未正確配置)上測試時一樣,AuthenticationContext.AcquireTokenAsync 方法失敗.

I do not have access to the Azure account but am confident the Service AD application is configured correctly to allow access to the Client AD application as when testing on an alternate account (not configured correctly) the AuthenticationContext.AcquireTokenAsync method was failing.

我確實注意到 AuthenticationResult.ExpiresOn 總是在過去,但看不到延長它的方法,這應該是未來的日期嗎? - (時間是當然UTC)

I did notice that the AuthenticationResult.ExpiresOn is always in the past but see no way of extending it, should this be a future date? - (Time is of course UTC)

請求:

GET https://example.azure
websites.net/api/categorisation HTTP/1.1
Authorization: Bearer eyJ0eXAiO...
Host: example.azurewebsites.net

回復:

HTTP/1.1 401 Unauthorized
Content-Length: 58
Content-Type: text/html
Server: Microsoft-IIS/8.0
WWW-Authenticate: Bearer realm="example.azurewebsites.net"
X-Powered-By: ASP.NET
Set-Cookie: ARRAffinity=e35f2977dba55e6708887e762940f75c2a0fcb0a9df4e1cbe0d3f10a614c59b8;Path=/;Domain=example.azurewebsites.net
Date: Fri, 08 Jul 2016 07:51:13 GMT

You do not have permission to view this directory or page.

更新:

我在我有權訪問的 Azure 帳戶中重新創建了環境,但仍然收到未經授權的響應(在瀏覽器中可以正常工作).

I have recreated the environment in an Azure account I have access to and still receive an Unauthorised response (works fine in a browser).

推薦答案

問題似乎與 Azure 網站中的身份驗證/授權"選項有關,啟用后,Web Api 將不接受使用身份驗證標頭的請求.禁用該選項并將 Owin 庫與 Azure AD 一起使用提供了所需的解決方案.

The issue appears to be with the "Authentication / Authorization" option in Azure Websites, when enabled the Web Api will not accept requests using the Authentication header. Disabling the option and using the Owin library alongside Azure AD has provided the solution required.

這篇關于Azure AD API 請求 401 未經授權的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 精品99爱视频在线观看 | 久久精品久久久久久 | 国产精品久久久99 | 亚洲精品9999 | 国产区视频在线观看 | 国产95在线 | 中文字幕成人av | 成人av高清| .国产精品成人自产拍在线观看6 | 国产在线一区观看 | 精品国产aⅴ | 嫩草懂你的影院入口 | 日韩精品在线播放 | 午夜激情免费 | 国产成人a亚洲精品 | 日韩电影在线一区 | 国产亚洲一区二区精品 | 精品国产乱码一区二区三区a | 日韩成人免费视频 | 亚洲成av人片在线观看 | 日韩欧美一区二区三区在线播放 | 中文字幕av中文字幕 | 国产中文字幕网 | 九色91视频 | 日本成人片在线观看 | 欧美一级二级三级视频 | av先锋资源| 美女天堂在线 | 午夜欧美| 精品欧美乱码久久久久久 | 久久亚洲精品久久国产一区二区 | 一级黄色夫妻生活 | 小川阿佐美pgd-606在线 | 国产免费一区二区三区最新6 | 国产精品久久久久久亚洲调教 | 日本成人中文字幕在线观看 | www.黄色网 | 欧美亚洲国语精品一区二区 | 激情一区二区三区 | 国产精品96久久久久久 | 国产在线精品一区二区三区 |