Workspace API token returns "Unauthorized" on all CLI commands in GitHub Actions
alonroth
PROOP

3 months ago

I'm setting up PR preview environments using the Railway CLI in GitHub Actions, following the official tutorial (https://docs.railway.com/guides/github-actions-pr-environment).

I created a workspace-scoped API token from the Railway dashboard (Workspace Settings > Tokens). The token is set as both RAILWAY_TOKEN and RAILWAY_API_TOKEN environment variables in the workflow.

Even the most basic command fails:

railway whoami

→ "Unauthorized. Please check that your RAILWAY_TOKEN is valid and has access to the resource you're trying to use."

Every CLI command fails with the same error — whoami, link, environment new, etc. The token is freshly generated and correctly set as a GitHub repo secret (verified it's not empty/malformed).

This appears to be the same issue reported here:

https://station.railway.com/questions/unauthorized-please-login-with-railway-22d6a137

Having a basic operation like token authentication not work is deeply concerning. If this can't be resolved quickly, we'll need to evaluate moving off Railway entirely.

$20 Bounty

3 Replies

Railway
BOT

3 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open Railway 3 months ago


You can't use scoped tokens to run commands such as whoami.


Also, you should be using a project scoped token.

https://docs.railway.com/cli/deploying#using-project-tokens


alonroth
PROOP

2 months ago

I've tried using project it didn't work.

What fixed it is to inline the secret -

RAILWAY_TOKEN=${{ secrets.RAILWAY_TOKEN }} railway up --service=XXXXXX

this guide is out-dated: https://blog.railway.com/p/github-actions


Welcome!

Sign in to your Railway account to join the conversation.

Loading...