Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Startup
- {
- public void Configuration(IAppBuilder app)
- {
- app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
- {
- Authority = ConfigurationManager.AppSettings["Authority"],
- RequiredScopes = new[] { "api" }
- });
- }
- }
- var claims = ((ClaimsIdentity)p.Identity).Claims;
- var roleClaim = claims.Where(i => i.Type == "client_role").FirstOrDefault();
- if (roleClaim == null)
- {
- return null;
- }
- private static TokenResponse GetToken()
- {
- var client = new OAuth2Client(new Uri(IdentityServerUri), clientId,clientScope);
- return client.RequestClientCredentialsAsync("scope").Result;
- }
- var client = new HttpClient();
- var tokenResponse = GetToken();
- client.SetBearerToken(tokenResponse.AccessToken);
- var result = client.GetStringAsync(requestUri).Result;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement