I am trying to trigger my dag with AirFlow rest API. However not able to understand how to do authentication.
Following URL works fine from my browser.
http://localhost:8181/api/experimental/dags/demo/dag_runs
However, Following code gives Authentication Error.
import requests
import json
from pprint import pprint
result = requests.get(
"http://localhost:8181/api/experimental/dags/demo/dag_runs",
data=json.dumps("{}"),
auth=("myuser", "mypassword"))
pprint(result.content.decode('utf-8'))
I found this as well, but now sure how to pass auth
https://github.com/apache/airflow/blob/master/airflow/api/client/api_client.py
By default the REST API rejects all requests. Make sure to set up the API auth backend as described in the docs:
[api]
auth_backend = airflow.api.auth.backend.basic_auth
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With