Skip to content

Construct default token_endpoint for msgraph filesystem#69522

Merged
dabla merged 1 commit into
apache:mainfrom
anmolxlight:fix-69463-msgraph-token-endpoint
Jul 15, 2026
Merged

Construct default token_endpoint for msgraph filesystem#69522
dabla merged 1 commit into
apache:mainfrom
anmolxlight:fix-69463-msgraph-token-endpoint

Conversation

@anmolxlight

Copy link
Copy Markdown
Contributor

Summary

When ObjectStoragePath is used with protocol="sharepoint" (or any msgraph protocol) and a connection that has client_id, client_secret, tenant_id but no explicit token_endpoint, MSGDriveFS fails because:

  1. Airflow's get_fs builds a non-None oauth2_client_params dict with client_id, client_secret, tenant_id
  2. MSGDriveFS.__init__ only constructs token_endpoint from tenant_id when oauth2_client_params is None
  3. AsyncOAuth2Client.fetch_token() gets no token endpoint URL → fails

Fix

When token_endpoint is not in oauth2_client_params and tenant_id is set, construct the default Microsoft identity platform v2.0 token endpoint:
https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token

This matches the exact URL msgraphfs builds internally when oauth2_client_params is absent (line 1470 of msgraphfs/core.py).

Test plan

  • Updated test_get_fs_with_drive_id to expect the auto-constructed token_endpoint
  • Updated test_get_fs_with_storage_options to expect the auto-constructed token_endpoint
  • Added test_get_fs_constructs_token_endpoint explicitly verifying the constructed URL
  • Existing test_get_fs_with_extra_oauth_params still passes — explicit token_endpoint in extras is honoured, not overwritten

Fixes #69463

@anmolxlight
anmolxlight requested a review from bolkedebruin as a code owner July 7, 2026 05:55
@eladkal
eladkal requested a review from dabla July 7, 2026 07:12
@anmolxlight
anmolxlight force-pushed the fix-69463-msgraph-token-endpoint branch from b2b779a to 01f5022 Compare July 7, 2026 10:44
@anmolxlight anmolxlight changed the title fix(microsoft-azure): construct default token_endpoint for msgraph filesystem (#69463) Construct default token_endpoint for msgraph filesystem Jul 7, 2026
When ObjectStoragePath is used with a sharepoint/msgraph protocol and
a connection that has client_id, client_secret, and tenant_id but no
explicit token_endpoint, MSGDriveFS fails because it receives a non-None
oauth2_client_params dict from Airflow and skips its own token_endpoint
construction logic, leaving AsyncOAuth2Client.fetch_token() without a
target URL.

Fix: if token_endpoint is not in oauth2_client_params and tenant_id is
set, construct the default Microsoft identity platform v2.0 token endpoint:
https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
@anmolxlight
anmolxlight force-pushed the fix-69463-msgraph-token-endpoint branch from 01f5022 to c7add20 Compare July 7, 2026 13:21
@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jul 8, 2026
@dabla
dabla merged commit d3a57b6 into apache:main Jul 15, 2026
83 checks passed
joshuabvarghese pushed a commit to joshuabvarghese/airflow that referenced this pull request Jul 16, 2026
apache#69522)

When ObjectStoragePath is used with a sharepoint/msgraph protocol and
a connection that has client_id, client_secret, and tenant_id but no
explicit token_endpoint, MSGDriveFS fails because it receives a non-None
oauth2_client_params dict from Airflow and skips its own token_endpoint
construction logic, leaving AsyncOAuth2Client.fetch_token() without a
target URL.

Fix: if token_endpoint is not in oauth2_client_params and tenant_id is
set, construct the default Microsoft identity platform v2.0 token endpoint:
https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token

Co-authored-by: Anmol Mishra <anmol.mishra@hellositi.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:microsoft-azure Azure-related issues ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Microsoft Graph Filesystem fails due to missing token_endpoint

3 participants