Setting Authorization Header of HttpClient

Stephen Hynes picture Stephen Hynes · Jan 31, 2013 · Viewed 719k times · Source

I have an HttpClient that I am using for a REST API. However I am having trouble setting up the Authorization header. I need to set the header to the token I received from doing my OAuth request. I saw some code for .NET that suggests the following,

httpClient.DefaultRequestHeaders.Authorization = new Credential(OAuth.token);

However the Credential class does that not exist in WinRT. Anyone have any ideas how to set the Authorization header?

Answer

Stephen Hynes picture Stephen Hynes · Jan 31, 2013

So the way to do it is the following,

httpClient.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", "Your Oauth token");