Kevin McMahon

Enthusiast

Blog Search

Authenticating to Heroku via CLI with MFA Turned On

Leaving this here for my future self.

Heroku has turned off interactive login and pushes folks to authenticate via a browser when authenticating to use the CLI app. This works fine if you don’t have MFA turned on (you should though!) and the flow completes without issue. If you do have MFA turned on, you’ll get a blank screen and a cryptic message (“IP address mismatch”) when attempting to complete the login.

To authenticate from the CLI you can follow this note from the Heroku Developer Docs and put your newly generated API key in a .netrc file or set and environment variable (HEROKU_API_KEY) or just enter the API key to the password prompt when interacting with the CLI.

➜  ~ heroku auth:login -i
heroku: Enter your login credentials
Email : [YOUR_EMAIL_HERE]
Password : [THE_API_KEY_YOU_GENERATED]

Logged in as [YOUR_EMAIL_HERE]