Cloud9 IDE Heroku Login - heroku

I need help logging into Heroku from Cloud9 IDE.
In a cloud9 IDE terminal, I enter heroku login and I don't get the chance to enter any credentials.
Instead I get the following
heroku: Press any kety to open up the browser to login or q to exit:
I hit any key and get the following:
heroku: Waiting for login...

According to the latest update, this shall work:
heroku login -i

Related

Web browser not pulling up after "pressing any key" to login to heroku

I'm using Git Bash to login to heroku. I'm at the part where I press any key to open the web browser so I can login. I've logged in via the command prompt and it opened the browser just fine. I've tried the heroku login -i method but when I enter my email address it doesn't do anything (just like pressing any key after prompted to do so). I added System32 to my PATH environment variable and have logged in via the command prompt, both of which seem to be the common solutions I can find.
If it helps, I'm trying to push a Python script I've written. I followed Codemy for creating the virtual environment, procfile, requirements.txt, etc. I've used git to add and commit everything, but I get stuck when asked to login. I've successfully logged in via the command prompt.
I tried it right now and it worked as expected. There were the steps:
Download installer https://devcenter.heroku.com/articles/heroku-cli
Install it
Open the cmd and enter: heroku login
It printed this
then a new tab in my default browser was opened
I entered my credentials with success. It showed the following message:
I closed the browser tab and finally I returned to the cmd:
After these steps, you could use any other git tool to perform git operations. Heroku login is just to store a kind of long live token in some part of the o.s.

Heroku cannot open browser to log in

I tried to log into Heroku via my command prompt by typing heroku login but this happened:
It says it cannot open my browser to log in. How should I proceed?
This just means that the Heroku CLI is having trouble opening the URL shown in your terminal for you.
Copy that URL and paste it into a browser of your choice, then log in.

Login to Heroku on remote server without a browser

Is there a way to login into Heroku to see the logs on a remote server which has no browser installed ?
Using Heroku CLI
$ heroku login -i
$ heroku logs

Automate Heroku CLI login

I'm developing a bash script to automatic clone some projects and another task in dev VM's, but we have one project in Heroku and repository is in it. In my .sh file I have:
> heroku login
And this prompt to enter credentials, I read the "help" guide included on binary and documentation but I can't found anything to automatic insert username and password, I want something like this:
> heroku login -u someUser -p mySecurePassword
Exist any way similar to it?
The Heroku CLI only uses your username and password to retrieve your API key, which it stores in your ~/.netrc file ($HOME\_netrc on Windows).
You can manually retrieve your API key and add it to your ~/.netrc file:
Log into the Heroku web interface
Navigate to your Account settings page
Scroll down to the API Key section and click the Reveal button
Copy your API key
Open your ~/.netrc file, or create it, with your favourite text editor
Add the following content:
machine api.heroku.com
login <your-email#address>
password <your-api-key>
machine git.heroku.com
login <your-email#address>
password <your-api-key>
Replace <your-email#address> with the email address registered with Heroku, and <your-api-key> with the API key you copied from Heroku.
This should manually accomplish what heroku login does automatically. However, I don't recommend this. Running heroku login does the same thing more easily and with fewer opportunities to make a mistake.
If you decide to copy ~/.netrc files between machines or accounts you should be aware of two major caveats:
This file is used by many other programs; be careful to only copy the configuration stanzas you want.
Your API key offers full programmatic access to your account. You should protect it as strongly as you protect your password.
Please be very careful if you intend to log into Heroku using any mechanism other than heroku login.
You can generate a non-expiring OAuth token then pass it to the CLI via an environment variable. This is useful if you need to run Heroku CLI commands indefinitely from a scheduler and you don't want the login to expire. Do it like this (these are not actual Tokens and IDs, BTW):
$ heroku authorizations:create
Creating OAuth Authorization... done
Client: <none>
ID: 80fad839-876b-4ea0-a41e-6a9a2fb0cf97
Description: Long-lived user authorization
Scope: global
Token: ddf4a0e5-9294-4c5f-8820-b51c52fce4f9
Updated at: Fri Aug 02 2019 21:26:09 GMT+0100 (British Summer Time) (less than a minute ago)
Get the token (not the ID) from that authorization and pass it to your CLI:
$ HEROKU_API_KEY='ddf4a0e5-9294-4c5f-8820-b51c52fce4f9' heroku run ls --app my-app
Running ls on ⬢ my-app... up, run.2962 (Hobby)
<some file names>
$
By the way this also solves the problem of how to use the Heroku CLI when you have MFA enabled on your Heroku account but your machine doesn't have a web browser e.g., if you are working on an EC2 box via SSH:
$ heroku run ls --app my-app
heroku: Press any key to open up the browser to login or q to exit:
› Error: quit
$ HEROKU_API_KEY='ddf4a0e5-9299-4c5f-8820-b51c52fce4f9' heroku run ls --app my-app
Running ls on ⬢ my-app... up, run.5029 (Hobby)
<some file names>
$
EDIT: For Windows Machines
After you run heroku authorizations:create, copy the "Token", and run the following commands:
set HEROKU_API_KEY=ddf4a0e5-9299-4c5f-8820-b51c52fce4f9
heroku run ls --app my-app
If your goal is just to get the source code, you could use a simple git client. You just need the api key.
Steps to get api key
Log into the Heroku web interface
Navigate to your Account settings page
Scroll down to the API Key section and click the Reveal button
Copy your API key
Download source code using git
Use this url template for git clone
https://my_user:my_password#git.heroku.com/name_of_your_app.git
In my case the user value was my email without domain.
Example :
if mail is **duke#gmail.com**
user for heroku auth will be **duke**
Finally just clone it like any other git repositories:
git clone https://duke:my_password#git.heroku.com/name_of_your_app.git
I agree that Heroku should have by now provided a way to do this with their higher level CLI tool.
You can avoid extreme solutions (and you should, just like Chris mentioned in his answer) by simply using curl and the Heroku API. Heroku allow you to use your API Token (obtainable through your user settings / profile page on the Heroku dashboard).
You can then use the API to achieve whatever it is you wanted to do with their command line tool.
For example, if I wanted to get all config vars for an app I would write a script that did something like the following:
-H "Accept: application/vnd.heroku+json; version=3" \
-H "Authorization: Bearer YOUR_TOKEN```
If *YOUR_APP_NAME* had only one config variable called *my_var* the response of the above call would be
{
"my_var": some_value
}
I've found using this all the time in CI tools that need access to *Heroku* information / resources.

Authentication failure in Heroku CLI after password change

After a password change on heroku's website, I can't access the heroku api.
When I do heroku login, I get Authentication successful, even though it shouldn't because the password has changed. It doesn't even ask for my email or password, like it should!
If I try heroku apps (or any other application related command), I get Authentication failure.
If I try heroku status, it works.
I don't have any plugins installed.
Logs:
$ heroku version
heroku-gem/3.6.0 (i686-linux) ruby/2.1.0
$ heroku logout
Local credentials cleared.
$ heroku login
Authentication successful.
$ heroku apps
Authentication failure
$ heroku plugins
You have no installed plugins.
I'll appreciate any help or ideas I can get. I already opened a ticket and waiting for the Heroku Support to get back to me.
Thanks
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
https://github.com/ddollar/heroku-accounts/issues/56
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. :)
heroku accounts:remove personal or whatever account name you have
git config --unset heroku.account
heroku accounts:add personal then login
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:
Removed the account (that's failing to authenticate) from heroku accounts:
heroku accounts:remove account_name
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.
Try deleting ~/.netrc (this is where the Heroku CLI tool saves the auth tokens) and starting over.

Resources