Google oauth airflow 2.8.0 Error 400: invalid_request

Hello folks, did anyone have try connecting airflow with google oauth?

I have this problem when sign in using oauth. I’m using docker-compose.yml with this environment variable set to my domain AIRFLOW__WEBSERVER__BASE_URL: https://airflow.mydomain.app and AIRFLOW__CLI__ENDPOINT_URL: https://airflow.mydomain.app . I’m also already set my webserver_config.py like following

import os
from flask_appbuilder.security.manager import AUTH_OAUTH
from airflow.configuration import conf

basedir = os.path.abspath(os.path.dirname(__file__))

# The SQLAlchemy connection string.
AUTH_TYPE = AUTH_OAUTH

AUTH_USER_REGISTRATION = True

AUTH_USER_REGISTRATION_ROLE = "Admin"

CSRF_ENABLED = True

# The SQLAlchemy connection string.
SQLALCHEMY_DATABASE_URI = conf.get('core', 'SQL_ALCHEMY_CONN')

OAUTH_PROVIDERS = [
    {
        'name': 'google',
        'icon': 'fa-google',
        'token_key': 'access_token',
        'remote_app': {
            "client_id": os.getenv("CLIENT_ID"),
            "client_secret": os.getenv("CLIENT_SECRET"),
            'api_base_url': 'https://www.googleapis.com/oauth2/v2/',
            'client_kwargs': {
                'scope': 'email profile'
            },
            'request_token_url': None,
            'access_token_url': 'https://accounts.google.com/o/oauth2/token',
            'authorize_url': 'https://accounts.google.com/o/oauth2/auth',
            'redirect_uri': 'https://airflow.mydomain.app/oauth-authorized/google',
        },
        'whitelist': ['@mydomain.app'], 
    },
]

is there any configuration that i miss to make my airflow url pointing to my domain?

Hey @dickymuhr

Apologies for the late reply, the error seems like to be not Airflow specific. But I think can be solved by replacing the private/local IP in the GoogleConsole by a fake FQDN (mydomain.com), then edit the local /etc/hosts file by pointing the private IP to the new FQDN.

Thanks
Manmeet

1 Like