public override async Task ValidateClientAuthentication( OAuthValidateClientAuthenticationContext context) { var userName = context.Parameters.Get("username"); var pass = context.Parameters.Get("password"); var userProvider = new UserProvider(new ExtraAirContext()); var user = await userProvider.FindByEmailAsync(userName); try { if (context.Parameters.Get("client") == null) { throw new Exception(); } } catch (Exception) { context.SetError( "invalid_grant", "type of client is undefined" ); context.Rejected(); return; } if (user != null && user.Password == pass) { await Task.FromResult(context.Validated()); return; } context.SetError( "invalid_grant", "The authentification code is invalid" ); context.Rejected(); return; }