HttpWebRequest 使用token访问 IdentityServer保护起来的api

HttpWebRequest request = WebRequest.Create("http://localhost:5001/identity") as HttpWebRequest;

request.Method = "GET";

var headers = request.Headers;
headers["Authorization"] = "Bearer " + key; //传递进去认证Token
request.Headers = headers;

HttpWebResponse response;

posted @ 2019-07-03 17:29  星星c#  阅读(3205)  评论(0编辑  收藏  举报