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

Multiple "firebase login" per client account #181

Closed
jennykwan opened this issue Jul 2, 2016 · 16 comments · Fixed by #3192
Closed

Multiple "firebase login" per client account #181

jennykwan opened this issue Jul 2, 2016 · 16 comments · Fixed by #3192
Assignees

Comments

@jennykwan
Copy link

Apologies if this was already raised. It would be nice for firebase login to not have to be client account wide (i.e. ~/.config/configstore/firebase-tools.json). I use an OSX machine, and deploy to multiple firebase accounts. Switching users on OSX is a PITA (and disrupts communication apps). Logging in and out of firebase is also not ideal. Ideally, the config would be stored in the project root (and I'd just .gitignore it).

Let me know where to look at a high level and I'll submit a PR. Or perhaps this already exists and I'm just using it wrong.

@idancali
Copy link

hey I need this too so I'm going to work on a fix for it and push a PR.
stay tuned and once it's out let me know if it works well for you too

@motin
Copy link

motin commented Nov 12, 2017

A workaround is to only require a single firebase login by choosing a google account to login with locally, and then use IAM to add access to all the various firebase projects that you need access to.

@piuccio
Copy link

piuccio commented Mar 26, 2018

Any chance that this will be looked at again? Apparently there's also a linked PR that would make our life easier

@teawaterwire
Copy link

As Firebase is getting into more and more companies, I know a lot of devs having this issue with firebase login: one account linked to their personal google account and another linked to their work google account. Having to logout/login is not critical, but not awesome either 😄

@jousi592
Copy link

jousi592 commented Apr 4, 2019

Please make this a feature, I am running 4 accounts and 20 different projects amongst them, its a real hustle when I update my master and have to merge it into all projects and then deploy all separately with individual accounts.

@adueck
Copy link

adueck commented Jun 28, 2019

Yes please! This would be a huge help!

@wodka
Copy link

wodka commented Jul 12, 2019

Even though this might be a lot of work: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html

for the amazon cli it is possible to pass a --profile NAME param for every cli call

@tienping
Copy link

tienping commented Oct 21, 2019

Any update on this feature? Was looking forward for this feature and can't wait to see how much easier my life will goes with this feature 🍡

@MarcDAFrame
Copy link

any update on this?

@bkendall
Copy link
Contributor

bkendall commented Dec 3, 2019

Thanks for all the comments here. We're aware of this as a feature request, but we lack in time to really look into this.

If someone was interested in making this into a PR of some kind, requireAuth is a likely place to start. That's the place where authorization tends to happen (and the usage can be tracked around the CLI).

There likely will be internal review because this would add new commands/flags to the CLI, but I think this may be reasonable to accomplish

@bean5
Copy link

bean5 commented Feb 13, 2020

@bkendall Still lacking time? I imagine there is a way to quickly switch configs behind-the-scenes, but I don't know enough of the internals of firebase tools to do that. For now, I have to re-auth* when context switching. It is an annoying overhead, particularly for locally-hosted CI/CD. Meaning, if I'm not watching it, I don't know that it wasn't that my build failed but that the deploy couldn't push.

@bean5
Copy link

bean5 commented Feb 13, 2020

So I found a work-around on Linux (Ubuntu).

When you login (but before you log out), your auth tokens are stored in ~/.config/configstore/firebase-tools.json.

For each company:

  • rename that file to be firebase-tools-[companyName].json
  • log into next company and repeat. If you copy the previous file instead of moving it, you'll probably end up logging out, which will invalidate what you copied. So DOT NOT do that.

Then I added the following aliases to my profile:

alias context.firebase.company1="cp ~/.config/configstore/firebase-tools-company1.json ~/.config/configstore/firebase-tools.json"
alias context.firebase.company2="cp ~/.config/configstore/firebase-tools-company2.json ~/.config/configstore/firebase-tools.json"

Not as elegant as I was hoping, but easier than learning the internals of the tool, proposing a PR, etc. Enjoy!

Tip: If you need to know which account you are currently using, just run firebase login. If your auth is valid, it'll spit out the email address.

@oluckyman
Copy link

oluckyman commented May 2, 2020

My case is much simple: I ocassionaly run distribution script for another account. Managed to do it without logging out from my main account:

firebase login:ci
# gives a token for the specified account.

Then I use that token to run a command from another account, like so:

firebase appdistribution:distribute AppFromAnotherAccount.ipa \
  --token "1//03To-kEntokEnt-Oken..."

When the command is finished I remain under my main account


Update: you can set this token to FIREBASE_TOKEN env variable.
I didn't test it but seems like you'll be able switch accounts by switching values of that variable.

@bean5
Copy link

bean5 commented May 8, 2020

@oluckyman I suppose that would work, but I think that functionality was mainly for use by servers/bots. Also, do you have to log in to the other account each time? I think the main reason this was opened was because some people get tired of logging in over and over again.

For example, I use a different browser for each client. Each password is unique and strong (very long). I definitely do not memorize them. I have to use the browser to authenticate or a password tool to retrieve the password.

Therefore I cannot create cron jobs that automatically deploy/update code. I have to be present.

@oluckyman
Copy link

@bean5 You have to login to get the token once. Then you provide token to any command and it runs as if you logged in to another account. No need to relogin.

@atlanteh
Copy link

atlanteh commented May 16, 2020

Hi all, I created a small cli helper that leverages login:ci to allow using multiple accounts on one machine. If you want, you're welcome to use it, and I'd love for some feedback and ideas :)
It's called firebase-multi and it's pretty easy to use:

  1. Install this module globally by running yarn add -g firebase-multi or npm i -g firebase-multi
  2. Run firebase login:ci and complete login flow until you get the firebase ci token in your terminal.
  3. Run firebase-multi set <your-project> <firebase-ci-token>
  4. Run in terminal/package.json script: firebase-multi use <your-project> firebase deploy (or any other firebase command that requires authentication)

All tokens are saved in ~/.config/configstore/firebase-multi.json

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

Successfully merging a pull request may close this issue.