Search code examples
python-3.xairflowairflow-webserver

Attempting to Trigger DAGS using API Key


I am running Apache Airflow Version 2.10.4.

I want to set up a DAG to receive data from a webhook from Dialpad. I can get the DAG to run with a curl command.

curl -X POST "https://Server/api/v1/dags/DagInQuestion/dagRuns" \
    --user "UserName:Password"
    -H "Content-Type: application/json" \
    -d '{
        "conf": {
            "json_data": "{Data}"
        }
    }'

The webhook does not support basic authentication. There is no basic authentication field, so I cannot enter my username and password in my URL. I can also not modify headers, meaning I cannot use a base64-encoded value.

I have attempted to set auth_backends = airflow.api.auth.backend.default in airflow.cfg which should disable authentication. However, I still face permission issues.

How do I configure Apache Airflow to accept POST requests without authentication?


Solution

  • I referred to the Airflow documentation and found that setting auth_backends = airflow.api.aith.backends.default in airflow.cfg only enables unauthenticated POST Requests through the experimental API. The webhook was able to post to the Airflow endpoint.

    curl -X POST "https://Server/api/experimental/dags/DagInQuestion/dag_runs" \
    -H "Content-Type: application/json" \
    -d '{
        "conf": {
            "json_data": "{Data}"
        }
    }'
    

    https://airflow.apache.org/docs/apache-airflow/2.7.1/security/api.html#basic-authentication