Skip to content

feat: add --non-interactive and --complete flags to stripe login#1511

Merged
bernerd-stripe merged 4 commits intomasterfrom
bernerd/non-interactive-login
Mar 25, 2026
Merged

feat: add --non-interactive and --complete flags to stripe login#1511
bernerd-stripe merged 4 commits intomasterfrom
bernerd/non-interactive-login

Conversation

@bernerd-stripe
Copy link
Copy Markdown
Contributor

Reviewers

r?
cc @stripe/developer-products

Summary

Adds two new flags to stripe login to support agent- and script-driven login flows:

  • --non-interactive: calls the Stripe auth endpoint, prints a JSON object with browser_url, verification_code, and a ready-to-run next_step command, then exits immediately. Also activates automatically when stdin is not a terminal.
  • --complete <url>: polls the given URL (from next_step) until the user approves in the browser, then saves credentials to the config file.

Together these enable a clean two-step flow for agents:

```

Step 1 – get links and exit

$ stripe login --non-interactive
{
"browser_url": "https://dashboard.stripe.com/stripecli/confirm_auth?t=...",
"verification_code": "excels-champ-wins-quaint",
"next_step": "stripe login --complete 'https://dashboard.stripe.com/stripecli/auth/...'"
}

Step 2 – complete after user approves in browser

$ stripe login --complete 'https://dashboard.stripe.com/stripecli/auth/...'

Done! The Stripe CLI is configured for Acme Inc with account id acct_...
```

The existing default browser+poll flow (stripe login) and --interactive flag are unchanged.

pkg/login/login.go adds InitiateLogin and PollForLogin, reusing existing GetLinks, keys.PollForKey, keys.RAKConfigurer, and SuccessMessage. pkg/cmd/login.go registers the flags, adds TTY auto-detection via golang.org/x/term, and updates the command's Long/Example docs.

Enables agent- and script-driven login without a TTY:

- `--non-interactive`: calls GetLinks, prints JSON with browser_url,
  verification_code, and a next_step command, then exits immediately.
  Also activates automatically when stdin is not a terminal.
- `--complete <url>`: polls the given URL from a prior --non-interactive
  run until the user approves in the browser, then saves credentials.

The existing default browser+poll flow and --interactive flag are
unchanged.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Committed-By-Agent: claude
@bernerd-stripe bernerd-stripe requested a review from a team as a code owner March 24, 2026 17:49
@bernerd-stripe bernerd-stripe force-pushed the bernerd/non-interactive-login branch from 64da879 to c2fdeb4 Compare March 24, 2026 21:29
@tomer-stripe
Copy link
Copy Markdown
Collaborator

this is great! i have two small things --

  1. so step 1 immediately exits, right? im wondering if we should give some kind of field with a time to expire (i think it's 10minutes) so the user knows.
  2. we should more explicitly say in the help that after running --non-interactive you really must run --complete right after to complete the flow. might be early for me but i didn't immediately connect the two

bernerd-stripe and others added 2 commits March 25, 2026 17:48
Make it clear that --non-interactive and --complete form a required
two-step sequence by updating the flag usage string and long description
to prompt users to immediately run the next_step command from the output.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Committed-By-Agent: claude
@bernerd-stripe
Copy link
Copy Markdown
Contributor Author

this is great! i have two small things --

  1. so step 1 immediately exits, right? im wondering if we should give some kind of field with a time to expire (i think it's 10minutes) so the user knows.

Discussed out of band; the server doesn't currently return this info so we'd be hard-coding it into the CLI. It's a good improvement, though, so I'll separately working on exposing that info to the client and then wire it up in a later PR!

  1. we should more explicitly say in the help that after running --non-interactive you really must run --complete right after to complete the flow. might be early for me but i didn't immediately connect the two

How does this look in 3a350f1

@tomer-stripe
Copy link
Copy Markdown
Collaborator

looks good, ty!

@bernerd-stripe bernerd-stripe merged commit 5d53b24 into master Mar 25, 2026
13 checks passed
@bernerd-stripe bernerd-stripe deleted the bernerd/non-interactive-login branch March 25, 2026 18:42
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