Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAILWAY_API_TOKEN is ignored when running railway link #575

Open
nathanlindsay opened this issue Nov 26, 2024 · 6 comments
Open

RAILWAY_API_TOKEN is ignored when running railway link #575

nathanlindsay opened this issue Nov 26, 2024 · 6 comments

Comments

@nathanlindsay
Copy link

nathanlindsay commented Nov 26, 2024

Running railway link -p ... after version 3.14.0 always results in "Unauthorized. Please login with railway login" even when RAILWAY_API_TOKEN is set

@brody192
Copy link
Contributor

Hello, Please make sure you are on the least version.

@nathanlindsay
Copy link
Author

Yes this applies to the latest version

@maddsua
Copy link
Contributor

maddsua commented Dec 11, 2024

Just checked the latest version in a CI and the only way for me to get this is by messing up branch protection rules that affect the variable. Could you share more of your context? Like, are you having that issue in CI, what's your env setup is, etc.?

@snide
Copy link

snide commented Dec 18, 2024

Confirming that I get this as well. It's when you are logged out.

I'm trying to build a CI pipeline in Github actions. Unfortunately nearly all of the CLI requires the project to be linked. You can't link without logging it, and settings RAILWAY_API_TOKEN or RAILWAY_TOKEN don't seem to matter.

Regardless of using the CLI in Github, I can see the same problem in a Linux env locally.

@maddsua
Copy link
Contributor

maddsua commented Dec 19, 2024

But why do you need to link a project?
When you create a project token in the dashboard this will automatically link that token to a specific project so that when you authorize the CLI with that token it will be already linked.

@nathanlindsay @snide

@snide
Copy link

snide commented Dec 19, 2024

@maddsua Because the vast majority of the CLI requires me to link it to use it's functionality. As a very concrete example, I need to set an environment variable for a DB_URL on build. In my case I want to build a github action that deploys a new environment for each PR and that passes in a unique env var per build. This would let me run a full flow where I isolate each PR with it's own preview, it's own DB (not hosted by railway), and can then pass that deployed preview URL to my test framework.

Vercel provides vercel env to do something like this.

Without allowing the railway CLI to be logged in, or run equivalent commands in a CI pipeline it's sort of neutered vs. running it locally where I can login and link.

Here's a full discussion on your discord about my usage.
https://discord.com/channels/713503345364697088/1318999369260859473

Ultimately, I went with Fly which seemed to support this stuff much better
https://fly.io/docs/apps/secrets/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants