Improve global auth token handling and errors#789
Open
cadeljones wants to merge 1 commit intorailwayapp:masterfrom
Open
Improve global auth token handling and errors#789cadeljones wants to merge 1 commit intorailwayapp:masterfrom
cadeljones wants to merge 1 commit intorailwayapp:masterfrom
Conversation
Previously the RAILWAY_TOKEN was being preferred over the RAILWAY_API_TOKEN if both were set. Now if both are set the RAILWAY_API_TOKEN is used by commands that require it. Also if the RAILWAY_TOKEN env incorrectly used for commands that require RAILWAY_API_TOKEN a helpful error message indicates the issue.
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.
About this PR
This is an attempt to clear up some common DX issues that arise when trying to authorize the CLI with tokens.
Context: #699
The CLI accepts to types of tokens as two separate env variables
RAILWAY_TOKENRAILWAY_API_TOKENThe two issues addressed in this PR
Previously the
RAILWAY_TOKENwas being preferred over theRAILWAY_API_TOKENif both were set.If the wrong token was used (eg
RAILWAY_TOKENfor whoami) the error was a generic Unauthorized warning.What was changed
The commands that require a global token can now specify that.
This enables two DX improvements
RAILWAY_API_TOKENis used by commands that require it.RAILWAY_TOKENis used incorrectly for commands that require RAILWAY_API_TOKEN a helpful error message indicates this issue.Possible future improvements
Ultimately the best DX would be a unified token env var and error messages that indicate if a scoped token is being used for a global command.
It would be possible to check on failure if the token is a valid scoped token and if it is indicate so to the user.
Something like this would do the trick