public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            try
            {
                var scope    = context.OwinContext.GetAutofacLifetimeScope();
                var services = scope.Resolve <IServiceFacade>();

                var user = await services.Security.AuthorizeAsync(context.UserName, context.Password);

                if (null == user)
                {
                    throw new Exception("The user name or password is incorrect.");
                }

                var identity = Principal.CreateIdentity(context.Options.AuthenticationType, user.Username, user.Id, user.IsAdmin);

                context.Validated(identity);
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, ex, "An error occurred while attempting to grant credentials");
                context.SetError(InvalidGrantError, ex.Message);
            }
        }