7 days ago
I have created a railway API token at this URL: https://railway.com/account/tokens scoped to my workspace. I have also tried with an API token not scoped to any workspace (i.e., leaving the dropdown empty).
I copy that token, and immediately run RAILWAY_API_TOKEN=... railway whoami. This returns "Unauthorized. Please check that your RAILWAY_TOKEN is valid and has access to the resource you're trying to use.". This also happens when I try to use this token in a GitHub workflow.
The token should be valid, as I just minted it.
It seems like a lot of other people are having similar issues, is there a fix?
3 Replies
Status changed to Awaiting Railway Response Railway • 7 days ago
Status changed to Awaiting User Response Railway • 6 days ago
noahd
What version of the CLI are you using?
6 days ago
Locally I'm using 4.37.2 which I installed maybe a month and a half ago through brew, in CI I'm using npm i -g @railway/cli which I expect to be whatever the latest version is.
Edit: I just upgraded through brew to 5.6.2 and it's still not working locally with a freshly minted token.
Status changed to Awaiting Railway Response Railway • 5 days ago
5 days ago
Your account is active and your approach is correct per our docs, so the token should work. Two things to rule out: first, make sure RAILWAY_TOKEN is not also set in your shell environment (setting both causes an error), and second, run railway logout before retrying to clear any cached session that may conflict with the env var. If it still fails after both of those, try hitting the API directly with curl using the same token in an Authorization: Bearer header to isolate whether the issue is CLI-specific.
Status changed to Awaiting User Response Railway • 5 days ago