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?
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 get 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:
curl -n https://api.heroku.com/apps/YOUR_APP_NAME/config-vars \ -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
I've found using this all the time in CI tools that need access to Heroku information / resources.
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:~/.netrc
file, or create it, with your favourite text editorAdd the following content:
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. Runningheroku 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:Please be very careful if you intend to log into Heroku using any mechanism other than
heroku login
.