Token based Authentication for WCF HTTP/REST Services: The Client
- by Your DisplayName here!
If you wondered how a client would have to look like to work with the authentication
framework, it is pretty straightfoward:
Request a token
Put that token on the authorization header (along with a registered scheme) and make
the service call
e.g.:
var oauth2
= new OAuth2Client(_oauth2Address);
var swt
= oauth2.RequestAccessToken(
"username", "password",
_baseAddress.AbsoluteUri);
var client
= new HttpClient {
BaseAddress = _baseAddress };
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer",
swt);
var response
= client.Get("identity");
response.EnsureSuccessStatusCode();
HTH