I have implemented an authorization server in a Asp.Net Web Api project as explained in this article.
Now I need to consume the service from a .Net c# client. In the IdentityModel documentation I can see below example:
var client = new TokenClient(
"https://server/token",
"client_id",
"secret");
var response = await client.RequestClientCredentialsAsync("scope");
var token = response.AccessToken;
Questions:
Scope
and what is the use of it?By using IdentityModel.Client;
the token can be consumed in following way.
var client = new TokenClient(authenticationUrl);
client.Timeout = TimeSpan.FromSeconds(60);
var tokenResponse = await client.RequestResourceOwnerPasswordAsync(userName, password);
var handler = new JwtSecurityTokenHandler();
var token = handler.ReadJwtToken(tokenResponse.AccessToken);
in the token
itself contains claim properties.