Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AuthorizationServerProvider : OAuthAuthorizationServerProvider
- {
- public override async Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
- {
- context.Validated();
- }
- public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
- {
- var identity = new ClaimsIdentity(context.Options.AuthenticationType);
- if (context.UserName == "user" && context.Password == "password")
- {
- identity.AddClaim(new Claim(ClaimTypes.Role, "user"));
- identity.AddClaim(new Claim("username", "user"));
- identity.AddClaim(new Claim(ClaimTypes.Name, "RaviRanjanKr"));
- context.Validated(identity);
- }
- else
- {
- context.SetError("invalid_grant", "Wrong credentials Used. Please Try again");
- return;
- }
- }
- }
Add Comment
Please, Sign In to add comment