Skip to content

Add stripe whoami command#1508

Merged
bernerd-stripe merged 6 commits intomasterfrom
add-whoami-command
Mar 26, 2026
Merged

Add stripe whoami command#1508
bernerd-stripe merged 6 commits intomasterfrom
add-whoami-command

Conversation

@bernerd-stripe
Copy link
Copy Markdown
Contributor

Reviewers

r? @
cc @stripe/developer-products

Summary

Adds stripe whoami, an offline command that reports the current auth state
without making any API calls. Intended for use in scripts and agent workflows
as a pre-flight check before running authenticated commands.

Text output:

$ stripe whoami
Profile:        default
Authenticated:  false
Run `stripe login` to authenticate.
$ stripe whoami --api-key sk_test_abc123456789
Profile:              default
Device name:          my-macbook
Test mode key:        available
Live mode key:        not available
API version:          2026-02-25.clover
Preview API version:  2026-02-25.preview

JSON output (--json):

{
  "authenticated": false,
  "profile_name": "default",
  "device_name": "my-macbook",
  "test_mode_key": {
    "available": false,
    "expires_at": null
  },
  "live_mode_key": {
    "available": false,
    "expires_at": null
  },
  "api_version": "2026-02-25.clover",
  "preview_api_version": "2026-02-25.preview"
}

Details:

  • Exit code 0 when authenticated, 1 when not — enables stripe whoami || stripe login
  • --api-key / STRIPE_API_KEY overrides are classified by key prefix (sk_test_ / sk_live_) so only the correct mode shows as available
  • --json schema is stable: test_mode_key and live_mode_key always present regardless of auth state

Adds an offline auth state command for use in scripts and agent workflows.
Reads credentials from config file and keychain without making any API calls.

- Reports active profile, key availability + expiry, and API version
- Classifies --api-key / STRIPE_API_KEY overrides by key prefix (sk_test_ /
  sk_live_) rather than reporting both modes as available
- Exits non-zero when not authenticated, enabling `stripe whoami || stripe login`
- Supports --json for stable structured output suitable for machine consumption

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 23, 2026 21:33
bernerd-stripe and others added 2 commits March 25, 2026 17:54
Standardize with other commands (listen, logs tail) that use --format
for output format selection. --format json produces identical output;
the flag change makes the interface consistent across the CLI.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Committed-By-Agent: claude
@bernerd-stripe bernerd-stripe merged commit 42d6b05 into master Mar 26, 2026
13 checks passed
@bernerd-stripe bernerd-stripe deleted the add-whoami-command branch March 26, 2026 22:29
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