Instantly share code, notes, and snippets.

Embed
What would you like to do?
Set your Github API Token If you hit a ”GitHub API rate limit exceeded” when searching with Homebrew (http://brew.sh/).

Description

PLEASE SCROLL DOWN AND READ THE COMMENTS FOR A MORE UP TO DATE WAY (AND EASIER) TO DO THIS
When using Homebrew (http://brew.sh) and searching formulas or pull requests you may get the dreaded error message: Github API Rate limit exceeded

Let's fix that! (yeah!)


Short version

PLEASE SCROLL DOWN AND READ THE COMMENTS FOR A MORE UP TO DATE WAY (AND EASIER) TO DO THIS
Create a new Personal Token in your Github Account Settings (Sidebar: Applications) and then copy the Token. In the Terminal, use export HOMEBREW_GITHUB_API_TOKEN=YOURAPITOKENWITHFUNKYNUMBERSHERE (change that to your API Token) or add that to your .bash_profile and then do source .bash_profile.

Step 1 - Create a Personal Access Token for Homebrew

  • Login to your Github Account or create one if you don't have one yet.
  • In the top menu to the right, click the tools icon (Account Settings).
  • Click on “Applications” in the sidebar (to the left).
  • In the box with the title “Personal Access Tokens”, press the “Create new token” button.

Note: As @rrotter mentions in the comments. ”UNCHECK EVERY SCOPE BOX when creating this token. There is no reason this token needs access to private information (unless you are developing brew casks in a private repo, but that's another issue)”. Credits to @rrotter

  • In the next box (Create a new Personal Access Token) set the name of your Token (i used homebrew but you can use anything you want). Press “Create Token”.
  • When done, you will see your token we just created in the “Personal Access Tokens” box. Copy the Token by select the token or click the copy icon to the right of the Token text.
  • The Token text should look something like this: 9927d2878ffa105fc5236c762f2fd7zfd28b841d (not a real token, just an example)

IMPORTANT! Remember To Keep The Token Safe As It Works As A “Password” For Your Github Account.

Step 2 - Set the Github API Token for Homebrew in the Terminal

  1. Fire up your Terminal.app (or iTerm.app)
  2. Use the command export HOMEBREW_GITHUB_API_TOKEN=9927d2878ffa105fc5236c762f2fd7zfd28b841d (but use your own API Token, and not the fake example one that don't work) and press enter.
  3. It's now set, however, instead of repating this every session, let's add this to our .bash_profile (if you don't know about this, see this link.)
  4. Open your .bash_profile in your favorite text editor (in this case, we use Nano in the Terminal). Make sure that you are in your Home directory (if unsure, use cd $HOME and press enter).
  5. Add the exact same line as in step 2. Press ctrl + o (to save) and then ctrl + x (to quit Nano)
  6. In your Terminal, do the command source .bash_profile (loads the changes in the .bash_profile file to the active session)
  7. Well, that's it!

###Helpful links


Tags: homebrew, brew, github api, token, api token, terminal, mac os x

@nshanker

This comment has been minimized.

nshanker commented Mar 12, 2015

hm, that doesn't seem to work (replaced some characters of token with FOOBAR for safety; also replaced IP address with XX.YY..etc)

6c40088fec0e:~ ect543$ date; echo $HOMEBREW_GITHUB_API_TOKEN
Thu Mar 12 14:49:10 PDT 2015
ff70766FOOBARTEST3987f2209eaa
6c40088fec0e:~ ect543$ date; brew search mysql
Thu Mar 12 14:49:18 PDT 2015
automysqlbackup mysql-cluster mysql-proxy
groonga-normalizer-mysql mysql-connector-c mysql-sandbox
mysql mysql-connector-c++ mysql-search-replace
mysql++ mysql-connector-odbc
Error: GitHub API rate limit exceeded for XX.YY.AA.BB. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
Try again in 20 minutes 53 seconds, or create an API token:
https://github.com/settings/applications
and then set HOMEBREW_GITHUB_API_TOKEN.
6c40088fec0e:~ ect543$

@rrotter

This comment has been minimized.

rrotter commented Apr 6, 2015

Please add to this that you should UNCHECK EVERY SCOPE BOX when creating this token. There is no reason this token needs access to private information (unless you are developing brew casks in a private repo, but that's another issue).

@warpedgeoid

This comment has been minimized.

warpedgeoid commented May 14, 2015

You should probably keep the public repo access scope.

@shpoont

This comment has been minimized.

shpoont commented Aug 6, 2015

@rrotter is right, you don't need any permissions for the token.

@christopheranderton

This comment has been minimized.

Owner

christopheranderton commented Aug 21, 2015

Thanks @rrotter, haven't seen the comments here (must have changed the notification settings). Added your comment to the Gist.

@dgentry

This comment has been minimized.

dgentry commented Oct 17, 2015

In addition to "Remember to keep the Token Safe" (which may not mean much to someone unfamiliar with OAuth tokens) you might explicitly suggest that if you publicly check in your .bash_profile or .bashrc (as many people do), that the token instead go in a separate, not-checked-in config file. This works for me:

In the file ~/.not-public:
export HOMEBREW_GITHUB_API_TOKEN=9927d2878ffakefakefake762f2fd7zfd28b841d

I do not check that file into a public repo, and keep its permissions u+rw, go-a (600).

In my .bashrc:

if [ -r ~/.not-public ]
then
    source ~/.not-public
fi
@ryanzzff

This comment has been minimized.

ryanzzff commented Nov 13, 2015

You can simply Step 2 into:

echo "export HOMEBREW_GITHUB_API_TOKEN=9927d2878ffa105fc5236c762f2fd7zfd28b841d" >> ~/.bash_profile
. ~/.bash_profile
@NitinBag0riya

This comment has been minimized.

NitinBag0riya commented Dec 18, 2015

Thanks :) Its works

@piermarcobarbe

This comment has been minimized.

piermarcobarbe commented Mar 27, 2016

The 4 itemized steps right under "Step 1" section should be revised. Now creating a token requires a step less.

@PilotatHeart

This comment has been minimized.

PilotatHeart commented May 19, 2016

UPDATE--Problem solved - See bottom of post for resolution. I decided to leave this post in case others have similar issues (let me know if it isn't useful and I will delete)

Original Post
Wow. I just wanted to migrate from Baseflight, to Cleanflight to make use of the 'Autotune' function. This seems SO complicated! Here is what I have done so far.. any assistance would be greatly appreciated.

  1. Opened Cleanflight, plugged in Naze 32 board (running Baseflight), in the firmware flasher made sure that "full chip erase" was checked, chose the most recent stable firmware (1.12.1 NAZE 2016-4-11 18:18 (stable), clicked "Load Firmware (online)," then clicked "Flash Firmware." Got a message "No response from the bootloader, programming failed"
  2. Exited all programs, restarted my computer, updated my Cleanflight configurator to the latest 1.2.2 which then gave me the "Github API Rate limit exceeded" warning. That brought me to this page where I walked through the above laborious steps of creating a API Token just so I could use Cleanflight. Wasn't sure where to enter my API Token, but found an area in the upper right of the screen beside Com port and Baud rate. Entered it there, and it allowed me to use the Cleanflight app again. Still, the same results.
  3. Put a jumper (paper clip) across the "Boot" pins on the board, clicked "No reboot sequence" then plugged in my board via USB. (no flashing light - just a steady blue light comes on) Same message "No response from the bootloader, programming failed"

I'm sure I am doing something wrong that is really basic but this is frustrating... Now, I can't even connect with the Naze using Baseflight. I haven't tried arming the board using the battery and controller, but I doubt that will work because the ESCs are all beeping when I plug in the battery.

Is there a way to erase the board completely and start fresh or...?

                               ***UPDADTE - 30 minutes later***

I went back to Baseflight and was able to reflash Baseflight using "Flash on connect, No reboot sequence, Full Chip Erase" Do I dare try to load cleanflight again or just resign myself to being a 'Baseflight' kind of guy?? :-)

And DARE I did. I went back to Cleanflight and did a "normal" firmware flash (Full chip erase checked, selected the most recent Naze 32 firmware, loaded it from online, and clicked "Flash Firmware") AND IT WORKED!!!

Lesson Learned: If you are having problems going from Baseflight to Cleanflight, reflash baseflight, then try Cleanflight again>?

@michaelchadwick

This comment has been minimized.

michaelchadwick commented May 23, 2016

Strangely, I created a personal access token, added it to a non-public, non-repoed dotfile that gets included in .bashrc, and despite re-sourcing it several times (and restarting iTerm), Github still complains. The Homebrew search (the function that keeps asking me to create the token) still fires, regardless, so I'm not sure how necessary the token really is, but I don't want to get blocked by the Github Police, in any case. I've tried the token with and without quotes, and I can echo it on the command line, so I feel like it's accessible.

Any thoughts?

@moooooooo

This comment has been minimized.

moooooooo commented Sep 4, 2016

thanks guys n gals. Works well.

@mkravchenko

This comment has been minimized.

mkravchenko commented Oct 7, 2016

thanks)

@esaruoho

This comment has been minimized.

esaruoho commented Jul 25, 2017

Query - how does one dump the API Token via Google Apps Script Editor? I am using the ImportJSON -bit of code I found online and it's telling me that I should send an Authenticated request because API rate limit has been exceeded..

@rjph99

This comment has been minimized.

rjph99 commented Nov 29, 2018

You can also get to Personal Access Tokens directly by going here: https://github.com/settings/tokens
or the modified instructions from Step 1 if you prefer to click stuff:
In the top menu to the right, click the tools icon and click on(Settings).
Click on “Developer Settings” in the sidebar (to the left).
In the box with the title “Personal Access Tokens”, press the “Create new token” button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment