Token based Authentication for WCF HTTP/REST Services: The Client
Posted
by Your DisplayName here!
on Least Privilege
See other posts from Least Privilege
or by Your DisplayName here!
Published on Tue, 15 Nov 2011 16:58:37 GMT
Indexed on
2011/11/15
18:06 UTC
Read the original article
Hit count: 538
IdentityModel
|IdentityServer
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
© Least Privilege or respective owner