Repository navigation
feat: log in again when a command finds no valid login - #446
Draft
angeloashmore wants to merge 3 commits into
Draft
angeloashmore wants to merge 3 commits into
angeloashmore wants to merge 3 commits into
Conversation
angeloashmore
force-pushed
the
claude/reauth-on-auth-error
branch
3 times, most recently
from
October 29, 2026 22:03
6f3d679 to
ac95676
Compare
A command stopped with a login error when the login was missing or expired. The developer had to run `prismic login` and the command again. Now the request that fails starts a login, waits for it, and retries with the new token. The command then continues. Parallel requests share one login, and later requests use the new token. - request takes an onAuthError handler for 401 and 403 errors. - Each client function that sends a token retries itself once with the token that the handler returns. The client does not know about the login. - getCredentials gives the handler. It does not log in when PRISMIC_TOKEN or CI is set. - Most services answer an expired login with a 403. On a 403, the handler checks the token first, so a user without access gets the usual error. - whoami and telemetry never start a login. - init and login share the new logIn function. - A login timeout is now a known error, not a reported bug. Closes #443 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L1dGD6G4hXCqeewEhox2Du
angeloashmore
force-pushed
the
claude/reauth-on-auth-error
branch
from
October 29, 2026 22:07
ac95676 to
e50c54a
Compare
A login that starts in the middle of a command now prints its URL and does not open a browser. prismic init and prismic login still open the browser unless --no-browser is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L1dGD6G4hXCqeewEhox2Du
getCredentials returns the host and a getToken function. A client
request asks getToken for the token. When the token is missing or
invalid, the request asks getToken({ login: true }) for a new one, which
starts the login. Later requests then get the new token.
The client now decides which errors mean an invalid token. getCredentials
only gives tokens. Commands pass host and getToken explicitly.
whoami, telemetry, and the error messages use allowLogin: false, so they
never start a login. init logs in with the browser before it changes the
project, as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1dGD6G4hXCqeewEhox2Du
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.
Resolves: #443
Description
Before this PR, a command stopped with an error when the login was missing or expired. The developer had to run
prismic loginand then run the command again. An agent had to read the error and do the same steps. Onlyprismic initstarted a login on its own.After this PR, the command prints a login URL, waits for the login, and continues from where it stopped. It does not open a browser, so the same flow works for a developer and for an agent that passes the URL on. All commands that use the Prismic API work this way.
prismic loginandprismic initstill open the browser, unless--no-browseris set. The CLI does not start a login whenPRISMIC_TOKENis set or in CI. A user without access to a repository still gets the access error.prismic whoamistill only reports the login state.This PR is stacked on #445.
Checklist
Preview
When no login is stored, the first line is
You are not logged in.How to QA 1
prismic logout.prismic repo list.🤖 Generated with Claude Code
https://claude.ai/code/session_01L1dGD6G4hXCqeewEhox2Du
Footnotes
Please use these labels when submitting a review:
⚠️ #issue: Strongly suggest a change.
❓ #ask: Ask a question.
💡 #idea: Suggest an idea.
🎉 #nice: Share a compliment. ↩