Apache Airflow Provider for Keycloak

raw JSON →
0.7.1 verified Fri May 01 auth: no python

An Apache Airflow provider package that integrates with Keycloak, enabling communication with Keycloak authentication servers. The current version is 0.7.1, supporting Airflow 2.7+ and Python >=3.10. Released on an as-needed basis.

pip install apache-airflow-providers-keycloak
error ModuleNotFoundError: No module named 'airflow.providers.keycloak'
cause Provider package not installed.
fix
Run: pip install apache-airflow-providers-keycloak
error AirflowException: The conn_id `keycloak_default` isn't defined
cause No Airflow connection configured for Keycloak.
fix
Create a connection with conn_id='keycloak_default' and conn_type='keycloak'.
error AttributeError: module 'airflow.providers.keycloak.hooks' has no attribute 'keycloak'
cause Incorrect import path (missing .hooks).
fix
Use: from airflow.providers.keycloak.hooks.keycloak import KeycloakHook
gotcha The hook requires a pre-configured Airflow connection with conn_type='keycloak'. Without it, you'll get a 'Connection not found' error.
fix Create a connection in Airflow UI or via environment variable AIRFLOW_CONN_KEYCLOAK_DEFAULT with JSON config.
deprecated The provider only supports Airflow 2.7+ and Python 3.10+.
fix Ensure your Airflow and Python versions are compatible.
breaking In older versions (pre-provider split), imports used 'airflow.hooks.keycloak'. This no longer works.
fix Use the new import path: from airflow.providers.keycloak.hooks.keycloak import KeycloakHook

Shows how to import and instantiate the KeycloakHook after setting up a connection.

from airflow import DAG
from airflow.providers.keycloak.hooks.keycloak import KeycloakHook
from datetime import datetime

default_args = {
    'owner': 'airflow',
    'start_date': datetime(2023, 1, 1),
}

with DAG('keycloak_test', default_args=default_args, schedule_interval=None) as dag:
    pass  # Use hook in tasks

hook = KeycloakHook()
# Hook is configured via Airflow connection 'keycloak_default'
print(hook.get_conn())