I am trying to update the Airflow connections using python. I have created a python function that takes an authentication token from API and updates the extra field of connection in Airflow.
I am getting token in json format like below:
{
"token" : token_value
}
Below is the part of python code that I am using
def set_token():
# Get token from API & update the Airflow Variables
Variable.set("token", str(auth_token))
new_token = Variables.get("token")
get_conn = Connection(conn_id="test_conn")
auth_token = { "header" : new_token}
get_conn.set_extra(str(auth_token))
But when I run the task, the extra field in airflow connection doesn't get updated. I can see that my Variable is getting updated but not connection. Could anyone please let me know what I am missing?