Loading video player…

Log In With the Heroku CLI

For more information on concepts covered in this lesson, you can check out:

Here are the command-line snippets used in this lesson:

Shell
$ heroku
$ heroku login
$ heroku whoami
$ heroku apps
$ heroku apps:info <app-name>

00:00 By the end of this lesson, you’ll know the basics of using the Heroku CLI, which is Heroku’s command-line interface. You’re going to need it to continue with this course, because from now on, pretty much every lesson will rely on this tool.

00:12 Don’t worry if you haven’t done a lot of work in the terminal before. The tool that you’re about to learn will make your life a lot easier. You can follow the installation instructions that you’ll find here on Heroku Dev Center, which hosts the official documentation and numerous step-by-step guides.

00:27 Choose the installation method that’s suitable for your operating system. For example, if you’re on a Mac, then you can use brew. For Windows, there’s a downloadable installer. And for Ubuntu, you can install the relevant package from snap. In case of facing any obstacles, there are always a few other installation methods available to you. However, before you do anything, make sure that you also have a Git client installed and configured. Heroku integrates with Git very tightly, which will become helpful later on.

00:57 And again, the specific installation instructions and steps will differ depending on your platform, so please follow the link in this callout here for more details on that.

01:08 To confirm the installation was successful, you can open your terminal now and type heroku.

01:15 As long as everything goes fine, it will show you the tool’s version and list available commands, which are called plugins. Don’t forget that there’s a list of all these commands for your reference available in the course supporting materials dropdown.

01:29 Most of these commands require that you’re logged into Heroku, and that’s understandable. While anyone can install the Heroku CLI on their computer, it will remain mostly useless until they actually identify themselves and prove that they have registered a Heroku account. Also, you might have more than just one account.

01:47 Maybe you have a personal and corporate account, so you need to specify which one you’d like to use in the current terminal session. The quickest way to look in is by typing the heroku login command.

01:58 It will prompt you to open a web browser, so when you hit Enter, it will open a temporary address in the Heroku domain using your default web browser, and it will try to leverage an existing session cookie to generate a new authorization token.

02:12 So if you’ve already gone to the Heroku dashboard in this browser, then you won’t have to type your password anymore. Just click the Log In button and return to the terminal.

02:21 Otherwise, you’ll be taken to the standard login page.

02:25 You should see your username being revealed. As a logged in user, you can now inspect your account straight from the command line. For example, you can check your identity again by typing heroku whoami.

02:39 Both of these commands you’ve seen so far are actually aliases of other commands. The Heroku CLI has a hierarchical interface with each command typically encapsulating one or more subcommands. In this case, whoami is in fact an alias of a similarly named subcommand of the auth plugin.

03:01 The auth plugin is also home to the login command that you used before. Remember, to display all plugins, just type heroku or heroku --help.

03:14 Some plugins have a default action associated with them. For example, typing heroku apps will display a list of your applications. To get more information about a specific app, use the info subcommand.

03:32 That’s pretty much all there is to the Heroku CLI. If you’d like to learn more about this tool, then head over to Heroku’s organization on GitHub and find the repository named cli. As you can tell, the Heroku CLI is written in JavaScript.

03:47 It’s built on top of Node.js and the Open CLI Framework, which means that you can check out the Heroku CLI source code or even contribute to it. Now that you have a Heroku account and Git client and you’re logged in with the Heroku CLI, you’re ready to create your first Heroku app that will be hosted in the cloud.

Become a Member to join the conversation.