fix(auth): RC_API_KEY outranks the stored OAuth login - #163
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7fa6fe7. Configure here.
RC_API_KEY outranks the stored OAuth login
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
davedelong
approved these changes
Aug 31, 2026
…y hints Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Rico's backend authenticates logins only; an sk_ key is rejected outright. Guard before the request with the actual remedy (unset RC_API_KEY / rc login) instead of the server's opaque 401. The Paywall AI editor does accept sk_ keys (offerings read_write scope), noted at its client. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Setting RC_API_KEY had no effect once a profile held an OAuth login — the stored login silently won, so scripts and CI runs could act on the wrong account. Env vars are the standard override everywhere else (gh, aws, stripe), so the credential order now matches: --api-key flag, then RC_API_KEY, then the OAuth login, then the stored key.
The existing multiple-credentials warning now reads the right way around, and a shadowed OAuth token no longer gets silently refreshed and re-saved on runs it isn't used for.
🤖 Generated with Claude Code
Note
Medium Risk
Changes global auth precedence and refresh behavior, which can shift which account commands use when OAuth and env keys coexist; impact is mostly clearer warnings and more predictable overrides.
Overview
RC_API_KEYand--api-keynow win over a profile OAuth login, matching typical CLI override behavior so CI and one-off env runs use the account they name instead of the logged-in profile silently.Credential resolution, conflict warnings, and docs are aligned with precedence flag →
RC_API_KEY→ OAuth → stored key.rc auth statusno longer shows cached profile email/name orauth_originwhen an env/flag override is active; conflict output names the shadowed login correctly. OAuth silent refresh runs only when OAuth is the active source, avoiding refresh/save of a token that is not in use. Fresh logins useSetOAuthTokens, which clears ambient overrides for the rest of the invocation likeSetAPIKey.Rico rejects
sk_credentials up front (login-only backend) with actionable errors, including whenRC_API_KEYoverrides a stored login. Paywall AI still accepts scopedsk_keys; Rico tests useatk_tokens.Reviewed by Cursor Bugbot for commit 12e36ae. Bugbot is set up for automated code reviews on this repo. Configure here.