✨ feat(login): use session login by default, move OAuth behind --oauth - #3
Merged
Merged
Conversation
…h flag Session login (email + password) is now the default authentication flow, with browser-based OAuth moved behind the --oauth flag. This prioritises the simpler, more reliable credential-based authentication for typical use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
pcloud loginfailed out of the box, for the CLI's own author:Three problems in one screen:
redirect with. The credential check sat below the banner.
--session, whichneeds no setup at all.
docs/authentication.mdxdocumented only the OAuth flow, including a"Create an OAuth application" section.
--sessionappeared nowhere.So the documented, default route required registering an OAuth application, while
the route that required nothing was invisible.
The default was inverted
Comparing the two tiers:
The default demanded more setup and delivered less capability. This is not a
new opinion in the codebase —
resolveStoredAuthalready prefers a stored sessiontoken over an access token, commented "the session token is the strictly more
capable tier", and
TRASH_OAUTH_WARNINGalready states OAuth cannot reach trashat all.
What changed
--sessionis kept as a no-op so existing muscle memory and any scripted usekeep working. Passing
--oauthand--sessiontogether is refused rather thansilently resolved — they ask for different things, so picking one for the user
would be a guess.
The OAuth credential check now runs before the banner, and its error offers
the way out:
Session login points back the other way too, so neither flow is a dead end.
Docs
docs/authentication.mdxrewritten to lead with session login and present OAuthas the deliberate alternative, opening with a comparison table so the choice is
made knowingly rather than by default.
docs/index.mdxhad drifted and is corrected alongside: it claimed Node 20(0.7.0 raised the floor to 24), described authentication as OAuth-only, and never
mentioned the
synccommands shipped in 0.7.0. The configuration table now marksthe client variables as
--oauth-only and documentsPCLOUD_AUTH.Breaking-ish
Anyone with
PCLOUD_CLIENT_ID+PCLOUD_CLIENT_SECRETexported who runs barepcloud loginwill now get a password prompt instead of a browser. Their fix isone flag,
--oauth, and existing stored tokens are untouched — nobody is loggedout by this. Auto-detecting on the presence of those variables was considered and
rejected: the same command behaving differently depending on environment is
harder to document and harder to predict than an explicit flag.
Testing
Six new tests in
src/login.test.ts, spawning the CLI with the client variablesstripped. Verified in both directions — each invariant was re-run against
deliberately reverted code, and each experiment failed exactly one test:
goes to session login, not OAuthdoes not promise a browser it cannot openThat second column is the point. The assertion worth making is not "the error
appears" — the error always appeared — but "the contradicting promise does not".
npm run typecheckclean, full suite 26 passing.