fix(auth): auto-provision staging environment after login#89
Merged
Conversation
After workos auth login succeeds, automatically fetch staging credentials and save them as a staging environment in the config store. This eliminates the need for users to manually run workos env add before management commands work. If the staging API fails (403/404/network), the login still succeeds and a hint is printed to configure an environment manually.
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.
Summary
After
workos auth loginsucceeds, the CLI now automatically fetches staging credentials and saves them as a default "staging" environment. This bridges the OAuth auth system with the API key system so management commands (e.g.,workos env list) work immediately without requiring a manualworkos env addstep.What was tested
Automated
pnpm typecheckcleanpnpm buildcleanManual
login.tsdiff verifiedprovisionStagingEnvironmentis called aftersaveCredentialsinrunLogin, wrapped in try/catch, returns booleanfalseand never throwisFirst || !config.activeEnvironmentguardstaging-api.tsandconfig-store.tsVerification
CLI-only change with no frontend UI. Verification based on comprehensive test execution and code review.
Screenshots
Issue
User-reported: after
workos auth login,workos env listshowed "No environments configured." Expected login to bootstrap a default environment.Follow-ups
--no-auto-envflag to skip auto-provisioning if needed