Skip to content

feat: add auth upgrade command to widen access to a superset of permissions - #229

Merged
dknudsen-stripe merged 1 commit into
mainfrom
dknudsen/auth-upgrade-command
Aug 6, 2026
Merged

feat: add auth upgrade command to widen access to a superset of permissions#229
dknudsen-stripe merged 1 commit into
mainfrom
dknudsen/auth-upgrade-command

Conversation

@dknudsen-stripe

Copy link
Copy Markdown
Contributor

Summary

Adds a new command to the CLI, link-cli auth upgrade [--scope] [--source-actions] [--authorization-details]. The new command unions the requested access with existing access (if any) to create a new login request. Upon success, it revokes and overwrites the existing access token.

Motivation

This command provides users and agents an ergonomic shortcut to stepping up their access from agentic-wallet only to add Financial Insights or vice versa. We may eventually provide an in-place upgrade path that doesn't require minting a new credential, but in the meantime this client-only flow is a workable mitigation.

Testing

Upgrade with no active credentials

dknudsen@st-dknudsen4(laptop) ~/stripe/link-cli % pnpm run link-cli auth status
✗ Not authenticated
Run "link-cli auth login" to authenticate

  Credentials: /Users/dknudsen/Library/Preferences/link-cli-nodejs/config.json
dknudsen@st-dknudsen4(laptop) ~/stripe/link-cli % pnpm run link-cli auth upgrade --scope userinfo:read
warning: no active session to upgrade; continuing with only the requested access.
✓ Successfully authenticated!
Credentials saved locally
dknudsen@st-dknudsen4(laptop) ~/stripe/link-cli % pnpm run link-cli auth status
✓ Authenticated

  Access token: liwltoken_1U1CSU2Feb...
  Token type: Bearer
  Scope: userinfo:read
  Credentials: /Users/dknudsen/Library/Preferences/link-cli-nodejs/config.json

Upgrade scopes

dknudsen@st-dknudsen4(laptop) ~/stripe/link-cli % pnpm run link-cli auth upgrade --scope payment_methods.agentic
✓ Successfully authenticated!
Credentials saved locally
dknudsen@st-dknudsen4(laptop) ~/stripe/link-cli % pnpm run link-cli auth status
✓ Authenticated

  Access token: liwltoken_1U1CUU2Feb...
  Token type: Bearer
  Scope: payment_methods.agentic userinfo:read
  Credentials: /Users/dknudsen/Library/Preferences/link-cli-nodejs/config.json

Upgrade authorization details

dknudsen@st-dknudsen4(laptop) ~/stripe/link-cli % pnpm run link-cli auth status
✓ Authenticated

  Access token: liwltoken_1U1Cl12Feb...
  Token type: Bearer
  Scope: userinfo:read,payment_methods.agentic
  Authorization details: [{"type":"source","actions":["read_external_transactions"],"resource_id":"csmrpd_61VA9dxZ7X53a7oKs412FebmrxrYhERs"}]
  Credentials: /Users/dknudsen/Library/Preferences/link-cli-nodejs/config.json
dknudsen@st-dknudsen4(laptop) ~/stripe/link-cli % pnpm run link-cli auth upgrade --source-actions read_balances
✓ Successfully authenticated!
Credentials saved locally
dknudsen@st-dknudsen4(laptop) ~/stripe/link-cli % pnpm run link-cli auth status
✓ Authenticated

  Access token: liwltoken_1U1Clc2Feb...
  Token type: Bearer
  Scope: userinfo:read payment_methods.agentic
  Authorization details: [{"type":"source","actions":["read_balances","read_external_transactions"],"resource_id":"csmrpd_61VA9dxZ7X53a7oKs412FebmrxrYhERs"}]
  Credentials: /Users/dknudsen/Library/Preferences/link-cli-nodejs/config.json

Abandoning upgrade mid-flow does not revoke existing auth

dknudsen@st-dknudsen4(laptop) ~/stripe/link-cli % pnpm run link-cli auth status
✓ Authenticated

  Access token: liwltoken_1U1Ckk2Feb...
  Token type: Bearer
  Scope: userinfo:read payment_methods.agentic
  Authorization details: [{"type":"source","actions":["read_external_transactions"],"resource_id":"csmrpd_61VA9dxZ7X53a7oKs412FebmrxrYhERs"}]
  Credentials: /Users/dknudsen/Library/Preferences/link-cli-nodejs/config.json
dknudsen@st-dknudsen4(laptop) ~/stripe/link-cli % pnpm run link-cli auth upgrade --source-actions read_balances

Authentication

╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                                              │
│  Open: https://app.link.com/device/setup?code=<REDACTED>│
│  Press Enter to open in browser                                                                                                                                                                                                                                              │
│  Enter phrase: <REDACTED>
│                                                                                                                                                                                                                                                                              │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

⠦ Waiting for authorization...

^C ELIFECYCLE  Command failed.

dknudsen@st-dknudsen4(laptop) ~/stripe/link-cli % pnpm run link-cli auth status
✓ Authenticated

  Access token: liwltoken_1U1Cl12Feb...
  Token type: Bearer
  Scope: userinfo:read,payment_methods.agentic
  Authorization details: [{"type":"source","actions":["read_external_transactions"],"resource_id":"csmrpd_61VA9dxZ7X53a7oKs412FebmrxrYhERs"}]
  Credentials: /Users/dknudsen/Library/Preferences/link-cli-nodejs/config.json

@dknudsen-stripe
dknudsen-stripe marked this pull request as ready for review August 5, 2026 22:01
@dknudsen-stripe
dknudsen-stripe requested a review from a team as a code owner August 5, 2026 22:01

@jlau-stripe jlau-stripe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested locally and overall looks good! Added a note on error handling!

poll_interval_seconds: authRequest.interval,
until: 'authenticated is true',
},
cli.command('upgrade', {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

update command without valid params acts like login. It's not harmful but I wonder if it should throw invalid command instead?

The something is just be testing to make sure it still works with invalid input

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It looks like this behavior is universal to all Link CLI commands that don't use positional arguments -- see below the payment-methods command has the same issue (see below). I would recommend we ignore for this PR and follow up with a separate change that adds validation messages for unknown positional args, WDYT?

dknudsen@st-dknudsen4(laptop) ~/stripe/link-cli % pnpm run link-cli payment-methods list LASDGLS

> @stripe/link-cli@ link-cli /Users/dknudsen/stripe/link-cli
> ./packages/cli/dist/cli.js payment-methods list LASDGLS


Update available for @stripe/link-cli: 0.10.1 -> 0.11.0
Run: npm install -g @stripe/link-cli
Payment Methods

  csmrpd_61VA9dxZ7X53a7oKs412FebmrxrYhERs  Chase Savings ****5115

});
scope = merged.mergedScope;
authorizationDetails = merged.mergedAuthorizationDetails;
} catch {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Invalid scope error message is not displayed. Would be nice to have that displayed

Image

Have to use --verbose flag to get the message displayed

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I get the same issue for auth login (see below). Since this is a pre-existing issue I'd like to fix it in a separate change, WDYT?

dknudsen@st-dknudsen4(laptop) ~/stripe/link-cli % pnpm run link-cli auth login --scope asdkjgalkgha    

> @stripe/link-cli@ link-cli /Users/dknudsen/stripe/link-cli
> ./packages/cli/dist/cli.js auth login --scope asdkjgalkgha


Update available for @stripe/link-cli: 0.10.1 -> 0.11.0
Run: npm install -g @stripe/link-cli
✗ Authentication failed
Device auth initiation failed (400): [object Object]

@dknudsen-stripe
dknudsen-stripe merged commit b3b3773 into main Aug 6, 2026
5 checks passed
@dknudsen-stripe
dknudsen-stripe deleted the dknudsen/auth-upgrade-command branch August 6, 2026 19:39
@damonnewman2121-bit

damonnewman2121-bit commented Aug 6, 2026 via email

Copy link
Copy Markdown

@damonnewman2121-bit

damonnewman2121-bit commented Aug 6, 2026 via email

Copy link
Copy Markdown

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.

4 participants