基于声明的安全性时的http客户端头授权

时间:2017-10-30 19:57:50

标签: c# asp.net-mvc rest web-services http

我从MVC应用程序调用REST api,其中使用基于声明的安全性。 我该如何设置身份验证标头? 我没有密码所以我想我不应该使用Basic。如果使用Bearer我如何获得令牌?

Client.DefaultRequestHeaders.Authorization= new AuthenticationHeaderValue(
    "Basic", Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(
    $"{"username"}:{"password"}")));

client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
    "Bearer",token);

0 个答案:

没有答案
相关问题