Setting Github API token for Homebrew

GithubHomebrew

Github Problem Overview


You need to set HOMEBREW_GITHUB_API_TOKEN for homebrew to avoid rate limiting, but how do you add it to homebrew config?

Github Solutions


Solution 1 - Github

You create your API token on https://github.com/settings/tokens and then set the environment variable HOMEBREW_GITHUB_API_TOKEN to the value of your token.

When creating the token, make sure that you only select the scopes you need. As pointed out in the answer by Chad, leaving all of the scopes unchecked is very reasonable!

Setting the token is done using the export command. Example:

export HOMEBREW_GITHUB_API_TOKEN=xxxx

To make sure this is set whenever you open a terminal you can add this command to your ~/.brew_bashrc or ~/.bash_profile or any other file that is used during the initialisation of your shell file.

For future reference, this topic was discussed in the following two issues:

Solution 2 - Github

Other than what @reto has already stated, it wasn't clear to me what scopes to select when creating a token. I was concerned about this, as I didn't want to allow too much.

According to https://gist.github.com/christopheranderton/8644743 they confirmed you should deselect all scopes. I've done this on my box and so far things work as expected.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkeypulsationsView Question on Stackoverflow
Solution 1 - GithubretoView Answer on Stackoverflow
Solution 2 - GithubChad GorshingView Answer on Stackoverflow