.NET HttpClient send arbitrary Authorization header

房东的猫 提交于 2019-12-13 17:04:38

问题


Using HttpClient is it possible to construct Authorization headers of arbitrary syntax ?

If I use the syntax HttpClient expects :

HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("OAuth2", <token>);

it will pass this header :

Authorization: OAuth2 <token-value>

However, I'm sending my requests to a remote REST API that requires the authorization header to be in this format :

Authorization: token <token-value>

How to send the required format ?

来源:https://stackoverflow.com/questions/30155552/net-httpclient-send-arbitrary-authorization-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!