访问ADFS服务器上的openid userinfo端点时未经授权访问401

访问ADFS服务器上的openid userinfo端点时未经授权访问401,openid,adfs,windows-server-2012-r2,userinfo,Openid,Adfs,Windows Server 2012 R2,Userinfo,我正在尝试使用WebClient API通过以下请求访问ADFS(非混合)上的用户的openId userInfo端点: //accessToken variable contains access token data string userInfoURL = "https://[base-server-url]/userinfo; Uri userInfoUri = new Uri(userInfoURL); WebClient client = new WebClient();

我正在尝试使用WebClient API通过以下请求访问ADFS(非混合)上的用户的openId userInfo端点:

//accessToken variable contains access token data
string userInfoURL = "https://[base-server-url]/userinfo;
Uri userInfoUri = new Uri(userInfoURL);
WebClient client = new WebClient();
client.Headers.Add(HttpRequestHeader.Authorization,"Bearer " + accessToken);
byte[] userInfoBytes = client.DownloadData(userInfoUri);
string response = Encoding.UTF8.GetString(userInfoBytes);
我已经成功地创建了一个新的应用程序组,其中包括一个服务器应用程序、一个Web API和OpenID连接协议。使用openid选项检查客户端权限。依赖方标识符的GUID与服务器应用程序的客户端ID相同

我在访问令牌请求期间包含了{“scope”,“openid”}。我不是在寻找自定义令牌的详细信息,而是来自openid范围的详细信息。根据我的研究,此请求中只能访问“子”值。我想继续讨论这个问题

在考虑访问令牌和oauth身份验证过程时,访问令牌和相关过程没有问题。但是userinfo端点访问失败

响应失败,出现“401”未经授权的错误

ADFS服务器的事件日志如下所示:

(1) 已收到具有以下属性的请求:

Date: 2020-07-16 09:48:38
Remote endpoint: remote-ip(Not disclosing details)
Local endpoint: local-ip(Not disclosing details)
Http method: GET
Request Url: /adfs/userinfo
Query string: ?access_token=eyJ0eXAiOi....(Not disclosing details)
Local Port: 443
User agent string: -
Body data length: 0
Caller Identity: -
Certificate Identity: -
Relying Party: -
Through proxy: False
Proxy name: -
Serialized Header: {"Host":"[host-name(Not disclosing details)]","X-MS-Endpoint-Absolute-Path":"/adfs/userinfo"}
(2) 存在以下请求上下文标头:

X-MS-Client-Application: -
X-MS-Client-User-Agent: -
client-request-id: -
X-MS-Endpoint-Absolute-Path: /adfs/userinfo
X-MS-Forwarded-Client-IP: -
X-MS-Proxy: -
X-MS-ADFS-Proxy-Client-IP: -
(3) UserInfoListener.ParseRequest:在请求中找不到访问令牌

(4)Sending response at time: '2020-07-16 09:48:38' with StatusCode: '401' and StatusDescription: 'Unauthorized'.
Response headers set: {"WWW-Authenticate":"Bearer error=\"invalid_token\", error_description=\"MSIS9923: Received invalid UserInfo request. Access token is not present in the request. The access token needs to be carried in Authorization Request Header Field or Form-Encoded Body Parameter.\"","Content-Type":"text/html; charset=utf-8"}
(5) UserInfoListener.WriteErrorResponse:UserInfo端点在处理请求时遇到错误。写入错误响应


非常感谢您的建议。

我也有同样的问题,您找到解决方案了吗?我也有同样的问题,您找到解决方案了吗?