Skip to content

OAUTHv2 Authentication #48798

@ozerpekozcan

Description

@ozerpekozcan

Description

Hi,

Currently, Airflow supports simple HTTP authentication. However, it would be beneficial to have built-in OAuth authentication, where the token URL, scope, and other HTTP parameters can be extracted from the connection. This would allow authentication using a token before making requests to the actual endpoint.

Additionally, if the token is expired, Airflow should automatically fetch a new one to prevent timeout errors. The implementation should retain all features of HttpOperator and HttpSensor, including support for deferrable execution.

This enhancement would improve security and reliability when integrating with OAuth-protected APIs.

Thanks,
Ozer

Use case/motivation

A customizable OAuth authentication mechanism would allow Airflow users to:

  • Define OAuth-specific parameters in Airflow Connections (e.g., token URL, scopes, client ID, client secret, grant type).
  • Automatically handle token renewal when expired, avoiding job failures.
  • Support both synchronous and deferrable execution, improving resource efficiency.
  • Extend the existing HttpHook, HttpOperator, and HttpSensor to support OAuth-based authentication without altering existing API logic.

Motivation:

  • Standardization – A unified OAuth authentication method ensures consistency across different APIs without custom coding for each integration.
  • Security – Storing OAuth credentials securely in Airflow Connections reduces exposure and enhances compliance with security policies.
  • Reduced Operational Overhead – Automating token retrieval and refresh eliminates the need for manual token management in DAGs.
  • Deferrable Execution Support – Avoids resource-intensive polling by deferring execution while waiting for authentication responses.
  • Scalability – Easily extendable to new APIs by simply updating connection details instead of modifying DAG logic.

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions