38

I would like to know what's the best way to switch between heroku account using the heroku toolbelt.

I'm used to have a personnal heroku account which is a collaborator of all of my professionnal heroku app. The problem is when I want to make some changes that have a financial impact : adding / removing addon for example, I cannot do it as a collaborator.
Before heroku toolbelt I was used to change the content of the file ~/.heroku/credentials but it does not exists anymore with the toolbelt.

Adrien Coquio
  • 4,870
  • 2
  • 24
  • 37

3 Answers3

32

Have you tried the heroku accounts plugin?

Piper Merriam
  • 2,774
  • 2
  • 24
  • 30
sylv3rblade
  • 621
  • 4
  • 8
25

In 2017, Heroku released heroku-accounts, an add-on to the toolbelt that lets one quickly switch accounts from the command line. Install it like this:

heroku plugins:install heroku-accounts

Then add an account ("work" in this case):

heroku accounts:add work

At this point, you'll need to provide the credentials you want associated with the "work" alias. Do the same for other accounts you have. Then switch between aliases like this:

heroku accounts:set work

(Sorry to zombie this question.)

IAmNaN
  • 10,305
  • 3
  • 53
  • 51
11

You can just run the login again from the command line:

heroku login

Enter your new email and password for the other account.

psyrendust
  • 1,186
  • 9
  • 13
  • 1
    it's too troublesome if we need to login and logout multiple times (and also entering password again and again) just to switch account. – Pahlevi Fikri Auliya Feb 19 '16 at 12:34
  • exactly what i was looking for – Walrus the Cat Oct 13 '16 at 20:32
  • Might not be the most efficient answer, but it helped me out! – skwidbreth Nov 29 '16 at 19:20
  • It's not working, the browser is just providing a button which says login. How can I login using a different account, after the "heroku login" command? – Amar Oct 19 '20 at 01:56
  • You have to create a new profile in your browser, log in to `heroku.com` and save the password, make sure the browser you're using is your default browser, make sure it's the only open browser window, and run `heroku login`. Now you can hit the "Login" button and log in to the CLI. I didn't wanna do all this, that's why I looked up "Multiple accounts in Heroku CLI" and came to this page. I think `@IAmNaN`'s answer could help me. I'm not sure... – Pyzard Dec 09 '20 at 05:59
  • Okay now I've tested `@IAmNan`'s answer. It works. – Pyzard Dec 09 '20 at 06:03