Skip to content

Add OAuth2 bearer token support for GCS #93

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

danklynn
Copy link

@danklynn danklynn commented Aug 3, 2025

Apache Polaris vends an OAuth2 access token for Iceberg tables hosted in GCS. This PR adds support for fetching files from GCS using these bearer tokens. Tested with read_parquet and iceberg_scan.

@Tmonster
Copy link
Contributor

Tmonster commented Aug 6, 2025

Hi.

Thanks for the PR!

So If I understand this correctly, Polaris is returning a OAuth2 token to be used when reading from a GCS bucket? I don't think the oauth2 credentials will be picked up when attaching to the iceberg rest catalog, but we should be able to add this soon.

Otherwise LGTM. Thanks for the tests.

@danklynn
Copy link
Author

danklynn commented Aug 6, 2025

Correct. Polaris vends credentials in the loadtable response if the X-Iceberg-Access-Delegation: vended-credentials header is provided in the request:

{
  "metadata" : ...,
  "metadta-location" : ...,
  "config" : {
    "gcs.oauth2.token": "{OAUTH2 BEARER TOKEN}",
    "gcs.oauth2.token-expires-at": "{milliseconds since epoch}"
  }
}

If we can get this merged, I can try to add support to the iceberg extension to support this functionality and pass the bearer token to httpfs. It would be great if we could get this in before the 1.4 freeze

danklynn pushed a commit to danklynn/duckdb-iceberg that referenced this pull request Aug 8, 2025
Polaris returns an OAuth2 bearer token for GCS tables like so:

{
  "metadata-location": "gs://my-bucket/warehouse/table/metadata.json",
  "config": {
    "gcs.oauth2.token": "ya29.a0AfH6SMBx..."
  }
}

This commit adds support for passing bearer tokens through to GCS.
This commit depends upon functionality added to the httpfs extension here:

danklynn/duckdb-httpfs@d5a7a2b

It will compile if you comment out https loading from `out_of_tree_extensions.cmake`
in the duckdb submodule, but this can be resolved once this PR is merged:

duckdb/duckdb-httpfs#93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants