-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(wrangler): add wrangler auth token command
#11682
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
Add a new command `wrangler auth token` that retrieves the current OAuth token, refreshing it if necessary. This is similar to `gh auth token` in the GitHub CLI and allows users to easily retrieve their authentication token for use with other tools and scripts. Fixes #10095 Co-Authored-By: [email protected] <[email protected]>
🦋 Changeset detectedLatest commit: e1e8955 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Claude finished @ascorbic's task —— View job Changeset Review✅ All changesets look good The changeset file
|
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
ascorbic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Tested locally.
|
Thanks for testing and reviewing! The PR is ready for merge whenever you're ready. |
|
(aside) This does need docs. I'll add them if everyone agrees this is the right API |
- Refactor getAuthToken to getOAuthTokenFromLocalState (only handles OAuth) - Rename LocalState to localState throughout user.ts - Add --json flag to return structured output with token type - Support API key/email auth with --json flag - Add JSDoc documentation for auth priority behavior - Update changeset to reflect all auth types - Update tests (24 tests passing) Co-Authored-By: [email protected] <[email protected]>
Add documentation for the new `wrangler auth token` command that retrieves authentication credentials for use with other tools and scripts. Documents: - Basic usage - --json flag for structured output with token type - Support for OAuth, API token, and API key/email auth types Related to cloudflare/workers-sdk#11682 Co-Authored-By: [email protected] <[email protected]>
vicb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Matt!
|
Ty ❤️ |
* feat(wrangler): add `wrangler auth token` command Add a new command `wrangler auth token` that retrieves the current OAuth token, refreshing it if necessary. This is similar to `gh auth token` in the GitHub CLI and allows users to easily retrieve their authentication token for use with other tools and scripts. Fixes cloudflare#10095 Co-Authored-By: [email protected] <[email protected]> * fix: output auth token without preamble and update snapshots Co-Authored-By: [email protected] <[email protected]> * fix: use printBanner: false for proper preamble suppression Co-Authored-By: [email protected] <[email protected]> * docs: add usage example to changeset per review Co-Authored-By: [email protected] <[email protected]> * feat(wrangler): add --json flag and refactor auth token command - Refactor getAuthToken to getOAuthTokenFromLocalState (only handles OAuth) - Rename LocalState to localState throughout user.ts - Add --json flag to return structured output with token type - Support API key/email auth with --json flag - Add JSDoc documentation for auth priority behavior - Update changeset to reflect all auth types - Update tests (24 tests passing) Co-Authored-By: [email protected] <[email protected]> * chore: trigger CI re-run for PR description validation Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Fixes #10095.
Adds a new
wrangler auth tokencommand that retrieves the current authentication credentials for use with other tools and scripts. This is similar togh auth tokenin the GitHub CLI.The command supports all Wrangler authentication methods:
wrangler login(automatically refreshed if expired)CLOUDFLARE_API_TOKENenvironment variableCLOUDFLARE_API_KEY+CLOUDFLARE_EMAIL(requires--jsonflag)Basic usage:
JSON output with token type:
Implementation notes:
printBanner: false--json(no single token to return)LocalStatetolocalStatefor consistencygetOAuthTokenFromLocalState()function that only handles OAuth tokens from local stategetAuthFromEnv()Human Review Checklist:
--jsonoutput format is appropriate for all three auth types--jsonis helpfulauthnamespace is the appropriate location for this commandDevin PR requested by [email protected]
Link to Devin run: https://app.devin.ai/sessions/d407c26dd1da4edf905944a95e90226a
wrangler auth tokencommand documentation cloudflare-docs#27219