from oauth.services.google import GoogleOAuthService from util.config.validators import BaseValidator, ConfigValidationException class GoogleLoginValidator(BaseValidator): name = "google-login" @classmethod def validate(cls, config, user, user_password, app): """ Validates the Google Login client ID and secret. """ google_login_config = config.get('GOOGLE_LOGIN_CONFIG') if not google_login_config: raise ConfigValidationException('Missing client ID and client secret') if not google_login_config.get('CLIENT_ID'): raise ConfigValidationException('Missing Client ID') if not google_login_config.get('CLIENT_SECRET'): raise ConfigValidationException('Missing Client Secret') client = app.config['HTTPCLIENT'] oauth = GoogleOAuthService(config, 'GOOGLE_LOGIN_CONFIG') result = oauth.validate_client_id_and_secret(client, app.config) if not result: raise ConfigValidationException('Invalid client id or client secret')