Trying to tap a private repo with token still asks for login

I’ve set up my own tap on a GitHub repository, and was able to tap it and install my one cask successfully. Since I want to include a few casks for software I can’t publicly share, I untapped the repo, set it to private, and am trying to set up access from Terminal to the repo again.

I’ve added this line to my ~/.bash_profile:

export HOMEBREW_GITHUB_API_TOKEN=3cb7158cf5826f3935a97ad97fd992dfe30e5f4f

(that’s not my real token, just a random generated 40 char hex. the real token has every scope checked for now, just to make sure that isn’t the issue.)

I’ve restarted the terminal, and also tried setting the HOMEBREW_GITHUB_API_TOKEN in Terminal itself for that session.

But every time I try to tap the repo with brew tap randallbruder/specialreserve, I get asked for my GitHub credentials:

Username for '': 
Password for '': 
remote: Repository not found.
fatal: Authentication failed for ''

As I have 2FA on my account, even entering the correct username and password still ends up with an authentication failure.

Any idea what I’m doing wrong? Thank you for any help!

I’m getting a 404 when trying to visit Is this a private repo? If so, you need to use the corresponding SSH URI to tap it, i.e. set up your GitHub account with an SSH key, then:

brew tap randallbruder/specialreserve

or tap with a URL that contains your API token:

brew tap randallbruder/specialreserve https://randallbruder:${HOMEBREW_GITHUB_API_TOKEN}

Correct, it’s a private repo.

Adding the API token variable/URL to the tap command worked, thank you for the help!

Homebrew is all git underneath so things like updates and installs will connect to your tap using git. The way you’re solving it now is just passing the credentials to git, but any method to have it remember the http credentials would work.