Authentication failure in Heroku CLI after password change

早过忘川 提交于 2019-11-30 02:08:47

After a password change on heroku's website, I can't access the heroku api.

Are you using the heroku-accounts plugin? If so, try uninstalling it.

heroku plugins:uninstall heroku-accounts
rm -r ~/.heroku/accounts
heroku logout
heroku login

Apparently, changing the password for heroku regenerates a new API key, and I had the wrong HEROKU_API_KEY configured. (It regenerates a new one after password change).

I'm posting here the response from the great Heroku's support team, which gave me these suggestions:

  • Is there a ~/.netrc file on your computer? If there is, can you please check if the file contains something Heroku related things? Please remove if there is, and try login again.
  • Is there an HEROKU_API_KEY environment variable defined on your machine? If yes, could you remove it and login try again?
  • Is there a ~/.heroku/credentials file (with or without an extension) on your machine? If yes, could you remove it and try login again?
  • Finally, if none of those work, could try the following command: GEM_HOME='' BUNDLE_GEMFILE='' GEM_PATH='' RUBYOPT='' heroku login and see how it goes?

Are you using the heroku-accounts plugin? If so, try uninstalling it.

You may not need to uninstall it...

Make sure you are not in a project directory (or you may run into the "account not found" loop).

cd

List your accounts.

heroku accounts

On each account where the password was changed

heroku accounts:remove ACCOUNT
heroku accounts:add ACCOUNT

(I did not need to do anything with the ~/.ssh/config.)

Reset your default account, if needed.

heroku accounts:default ACCOUNT

If you changed the account name or git config --unset heroku.account.

cd /path/to/your/project
git config --add heroku.account ACCOUNT

I didn't want to give up on the heroku-accounts plugin. :)

In my case, I had multiple heroku accounts managed by heroku-accounts gem and authentication started failing after I changed one of my account's password.

Steps I followed to make things normal again:

  1. Removed the account (that's failing to authenticate) from heroku accounts:

    heroku accounts:remove account_name

  2. Opened up a new terminal and then added the account again that I just deleted:

    heroku accounts:add account_name --auto

Here you have to use your new credentials.

That's it. Problem solved.

heroku accounts:remove personal or whatever account name you have

git config --unset heroku.account

heroku accounts:add personal then login

Try deleting ~/.netrc (this is where the Heroku CLI tool saves the auth tokens) and starting over.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!