RAILWAY_TOKEN not working on cli
kamihouse
HOBBYOP

a month ago

I recently renewed the tokens for one of my projects.

I did this a few days ago and was unsuccessful in authenticating. I've now created a new project-scoped token and testing with railway_cli on my equipment, setting the environment variable RAILWAY_TOKEN.

railway -V
railway 4.30.2

When I run the command railway status, I receive the following output:

Project: brer
Environment: production
Service: None

However, when I run the following commands, I receive an authentication failure: railway project list

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

When I run the command: railway service status -a

MySQL                | 22a559c5-d3c5-49c7-... | STOPPED
Redis                | 724bba54-634d-4bab-... | SUCCESS
marketplace          | 02a2f278-ae3e-4ba5-... | SUCCESS
api                  | 9391d464-9639-4078-... | SUCCESS
php-fpm              | fd288187-f446-4ee4-... | SUCCESS

And also testing the commands: railway link ,railway link -s marketplace and railway link -e production -p brer -s marketplace , returning:

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

Please, I need help.

Solved$10 Bounty

Pinned Solution

kamihouse
HOBBYOP

a month ago

Works @diogoribeirodev

1. At personal account, create a token, DONT SELECT A WORKSPACE.

  1. Get the token and use it as RAILWAY_API_TOKEN

11 Replies

kamihouse
HOBBYOP

a month ago

railway -V
railway 4.30.1

Attachments


Are you using a project scoped token?


kamihouse
HOBBYOP

a month ago

I'm testing the new version of the CLI, but experiencing the same error.

railway -V
railway 4.30.2

0x5b62656e5d

Are you using a project scoped token?

kamihouse
HOBBYOP

a month ago

This token is for the project, not for API.

Scope applies to the API token (I've also encountered this type of issue).


diogoribeirodev
FREETop 5% Contributor

a month ago

railway project list applies to your account not the project itself. Since the token is for the project only, it won't work for neither.
railway status works bc is lists information of the current project.

railway project list , list all projects under your account.
railway list , lists all projects under all of your workspaces.


diogoribeirodev
FREETop 5% Contributor

a month ago


diogoribeirodev

more info https://docs.railway.com/integrations/api#choosing-a-token-type

kamihouse
HOBBYOP

a month ago

This is not an API token, but rather a project-scoped token.


kamihouse

This is not an API token, but rather a project-scoped token.

diogoribeirodev
FREETop 5% Contributor

a month ago

That is what i said, everything that you’re trying to do, won’t work with a project scoped token ( which itself is an API Token, since it interacts with the railway api, the same a way an account/org scoped token)

Attachments


diogoribeirodev
FREETop 5% Contributor

a month ago

You’re trying to run commands that aren’t available for project scoped tokens, as per the docs i shared above


kamihouse
HOBBYOP

a month ago

Works @diogoribeirodev

1. At personal account, create a token, DONT SELECT A WORKSPACE.

  1. Get the token and use it as RAILWAY_API_TOKEN


diogoribeirodev
FREETop 5% Contributor

a month ago

Great!


Status changed to Solved brody 26 days ago


Loading...