Skip to content

feat(cli): add token parameter for rest catalog - #549

Merged
zeroshade merged 1 commit into
apache:mainfrom
rodrigopv:feat-add-token-cli-parameter
Aug 28, 2025
Merged

zeroshade merged 1 commit into
apache:mainfrom
rodrigopv:feat-add-token-cli-parameter

Conversation

@rodrigopv

Copy link
Copy Markdown
Contributor

This PR adds support for a --token parameter to enable direct Bearer token authentication with Iceberg REST catalogs, bypassing the OAuth flow when a valid token is already available.

Changes

  • Added --token CLI parameter: Accepts a pre-issued Bearer token for direct authentication
  • Authentication priority: When both --token and --credential are provided, --token takes precedence
  • Backward compatibility: Existing --credential OAuth flow remains unchanged and fully supported

Example

go run ./cmd/iceberg --uri https://catalog.cloudflarestorage.com/$ICEBERG_CATALOG_PATH --token $CATALOG_TOKEN --warehouse $WAREHOUSE list

output:


┌─────────┐
| IDs     |
| ------- |
| default |
└─────────┘

API Impact

This change only affects the CLI interface. The underlying REST catalog API already supports both authentication methods through rest.WithOAuthToken() and rest.WithCredential() options.

@zeroshade

Copy link
Copy Markdown
Member

How is this different from the credential option that already exists?

@rodrigopv

Copy link
Copy Markdown
Contributor Author

How is this different from the credential option that already exists?

credential accepts a colon-separated client_id and client_secret to perform OAuth2 authentication, which returns a bearer token as a response.

token allows you to directly use a pre-issued bearer token. Some providers such as Cloudflare R2 Data Catalog give you a bearer token right away, that's why I needed to implement this (still just for the comfort of using the CLI, as the API already supports passing a token).

So this PR allowed me to test drive this Iceberg catalog REST service right away with the iceberg-go CLI instead of the suggested options in Cloudflare documentation.

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Thanks!

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