Feature request: easier toggling between accounts using flyctl

As mentioned in another thread, I have a few different (Elixir/Phoenix) projects that I’m migrating over to fly, some on my personal account, some for my employer.

Because I have to work across multiple accounts, I have to keep logging out/in to switch between them. It is not a great workflow.

It would be great if flyctl could authenticate into multiple accounts, and then use the account (and org) that was assigned in the fly.toml in the project. Eg:

[auth]
  account = "my-account"
  organisation = "my-brand"
1 Like

This is not obvious, but we designed Fly so that you’d have a single user account and add it to multiple organizations (similar to GitHub). Will just adding your primary user to the other orgs work for what you need?

That would work, if I can simply add my gh user to the business account. I’ll explore.

Did you make business organizations in Fly, or signup for whole new accounts? If you made new organizations, you can invite your primary user. If you didn’t, we can help you get those reconciled. Just send me a DM with your primary user and the accounts you made specifically.

Whole new accounts. My personal and business accounts can’t be reconciled into one, unfortunately.

Ok, let me know if you want us to convert those business accounts to “organizations” and add your user to them.

To answer your original question, one way to handle different logins is to use something like direnv.net to set the right FLY_ACCESS_TOKEN environment variable for your project directories. When you’re logged in, you can run fly auth token.

Assuming you in a directory for a particular app, you can run something like this:

echo "export FLY_ACCESS_TOKEN=$(fly auth token)" > .envrc

If you group your projects into directories by business, you should be able to add a single .envrc for each “business” and have the project directories inherit that.

1 Like

Ah, wonderful! I’m already using direnv! I’ll give that a try. :+1:t2:

Unfortunately it looks like I can’t invite myself (personal email) to my employer’s account. The invite is sent but the accept fails.

I still think it would be preferable in a number of cases for flyctl to be the place to manage auth between accounts. For example, in a case where a web agency needs to have access to multiple client-owned accounts, along with their own account split into orgs for clients who don’t need direct access to fly.

@kurt @jerome Also, something I’ve noticed in all the switching between accounts:

This shows up on the fly.io homepage when I’m logged in:

And this shows up when I’m logged out (or if I use an incognito window in a different browser):
Screen Shot 2021-06-08 at 14.31.54

This should be the other way around, no? :upside_down_face:

Oops! Thanks for letting us know, should be fixed now.

1 Like