-
Notifications
You must be signed in to change notification settings - Fork 16.3k
feat-51094: add OAuth 2 / XOAUTH2 support via auth_type & token/credential extras
#53554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hi @eladkal, I’ve moved all the changes from With that done, I think this PR is ready to merge for the new feature, and we can handle deprecating |
|
Nice! where we explain the different options and how to set them.
That would be great! |
Agree. More user docs is better. |
|
Sure, let me work on that. |
…as (apache#53554) * support auth_type=oauth2 for smtp * add auth_type to notifications * add ut for build_xoauth2_string & send_mime_email * add test for smtp * add test for notifications * add ui widgets & property for oauth2 * add extra parameters to the docs * fix CI test * fix CI test apache#2 * fix CI test apache#3 * expose `build_xoauth2_string` & add fallback for old cores * rollback email.py and test_email.py & refactor smtp.py * refactor the doc to enrich examples and explnations
…as (apache#53554) * support auth_type=oauth2 for smtp * add auth_type to notifications * add ut for build_xoauth2_string & send_mime_email * add test for smtp * add test for notifications * add ui widgets & property for oauth2 * add extra parameters to the docs * fix CI test * fix CI test apache#2 * fix CI test apache#3 * expose `build_xoauth2_string` & add fallback for old cores * rollback email.py and test_email.py & refactor smtp.py * refactor the doc to enrich examples and explnations
…as (apache#53554) * support auth_type=oauth2 for smtp * add auth_type to notifications * add ut for build_xoauth2_string & send_mime_email * add test for smtp * add test for notifications * add ui widgets & property for oauth2 * add extra parameters to the docs * fix CI test * fix CI test #2 * fix CI test #3 * expose `build_xoauth2_string` & add fallback for old cores * rollback email.py and test_email.py & refactor smtp.py * refactor the doc to enrich examples and explnations
…as (apache#53554) * support auth_type=oauth2 for smtp * add auth_type to notifications * add ut for build_xoauth2_string & send_mime_email * add test for smtp * add test for notifications * add ui widgets & property for oauth2 * add extra parameters to the docs * fix CI test * fix CI test apache#2 * fix CI test apache#3 * expose `build_xoauth2_string` & add fallback for old cores * rollback email.py and test_email.py & refactor smtp.py * refactor the doc to enrich examples and explnations
|
@eladkal Do you know if this is intended to make its way into the 2.x Airflow release at some point, or will it only be 3.x ? (Hope it's alright to ask here.) |

Closes: #51094
Why
Airflow does not currently support OAuth for SMTP. Microsoft is removing BasicAuth as capability from Exchange Online globally this September 2025 (Source: Microsoft announcement).
How
send_email_smtp/send_mime_emailnow acceptauth_type="oauth2"and an optionalaccess_token.SmtpHook,SmtpNotifier, andEmailOperatoracceptauth_type; the hook reads eitheraccess_tokenorclient_id+client_secretfrom Connection extra.auth_type,access_token,client_id, …).What
Step 1
Use the Goole Oauth Playground to obtain an
access_token.Step 2
Start Airflow locally with
breeze start-airflowand add a connection:Step 3
Tested by run this DAG
Or add in
airflow.cfgThen in a Python shell:
Step 4
Confirm the message arrived in mailbox.
