-
Notifications
You must be signed in to change notification settings - Fork 0
Airflow API
Sean Sy edited this page Oct 12, 2021
·
1 revision
Airflow also has an API that you can communicate with.
In Airflow 1.x, it is called the experimental REST API. By Airflow 2.x, this experimental API has been deprecated in favor of the stable API.
To enable the API, which denies all requests by default in Airflow 1.x, add these configurations to the airflow.cfg
[api]
# How to authenticate users of the API. Default value denies all API
# requests (airflow.api.auth.backend.deny_all)
auth_backend = airflow.contrib.auth.backends.password_auth
Password authentication will require flask-bcrypt to be installed as well.
One quirk of the experimental REST API is that user accounts tied to use of the API are separate from the user accounts in the RBAC UI. To create an API user, run this Python snippet
import airflow
from airflow import models, settings
from airflow.contrib.auth.backends.password_auth import PasswordUser
user = PasswordUser(models.User())
user.username = 'new_user_name'
user.email = 'new_user_email@example.com'
user.password = 'set_the_password'
session = settings.Session()
session.add(user)
session.commit()
session.close()
exit()