Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Airflow - rest API Authentication

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

like image 373
Gaurang Shah Avatar asked Jan 19 '26 15:01

Gaurang Shah


1 Answers

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
like image 60
0x5453 Avatar answered Jan 22 '26 13:01

0x5453