21

Fresh installed a laravel/homestead vagrant box, as per docs, run the init.sh, configured Homestead.yaml and ran $ vagrant up; vagrant ssh. Afterwards cd'ed to project's folder and ran composer install.

It hangs waiting for a token with the following message

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
- Installing sebastian/diff (1.3.0)
Downloading: Connecting...
Could not fetch https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3, please create a GitHub OAuth token to go over the API rate limit
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+homestead+2015-08-01+2140
to retrieve a token. It will be stored in "/home/vagrant/.composer/auth.json" for future use by Composer.
Token (hidden):

I have used laravel/homestead before, and I have never had to do any of these, is this some undocumented new feature or a bug or did I do something wrong?

baao
  • 71,625
  • 17
  • 143
  • 203
Christopher Francisco
  • 15,672
  • 28
  • 94
  • 206

5 Answers5

41

You'll need to create a GitHub account if you don't already have one and then follow the instruction here and then copy the token.

Once you've got your token, run composer install again and then paste the token in when it prompts you for it.

kenorb
  • 155,785
  • 88
  • 678
  • 743
Rwd
  • 34,180
  • 6
  • 64
  • 78
  • 6
    Well this solved it. I'm just confused about why did it suddenly asked for a token; like, I've been using Laravel for a year now, never got asked for a Token. – Christopher Francisco Aug 03 '15 at 13:45
  • how to run composer install again in command line in windows? – Eli Feb 13 '16 at 11:02
  • 3
    The reason you suddenly have to do this even though you have never had to do so before is that you have gone over the Github API rate limit, which is currently 60 requests per hour. – Russ Feb 17 '16 at 10:30
6

The error means that you have exceeded the API rate limit for your IP address.

You can either:

  • wait a bit and re-try again,
  • change your IP address (e.g. by connecting via proxy or VPN),
  • specify your authentication token as suggested by the message:

    Please create a GitHub OAuth token to go over the API rate limit Head to https://github.com/settings/tokens/new?scopes=repo

    and pass into your Composer command or add it manually into ~/.composer/auth.json, e.g.

    {
        "http-basic": {},
        "github-oauth": {
            "github.com": "__TOKEN__"}
    }
    

    Note: On Windows, it's in %APPDATA%/Composer.

    or add the settings manually by the following commands (as per this comment):

    composer config -g --unset github-oauth.api.github.com
    composer config -g github-oauth.github.com __TOKEN__
    
kenorb
  • 155,785
  • 88
  • 678
  • 743
0

Go to settings then Developer settings from personal access token you can generate a new token

enter image description here

Omar Makled
  • 1,638
  • 1
  • 19
  • 17
0

Go into your github account: https://github.com/settings/tokens/new then generate a new token copy then add it into your the terminal like that

composer config --global --auth github-oauth.github.com your_token_here
Rachid Loukili
  • 623
  • 6
  • 15
0

Just for completeness' sake:

I had an expired token sitting in my Composer auth.json file, which resulted in me getting prompted for a new token despite not hitting the Github API limit.

In my case, I simply had to nano ~/.composer/auth.json and drop my old tokens from the github-oauth section. I also deleted all of my expired Github tokens as well, just to make sure.

Once I cleared out the cruft, everything began functioning as expected for me.

If one indeed has hit the API limit, then there's no way around it and my answer probably won't help. But it might be worth checking into first before creating a whole new token.

maiorano84
  • 11,574
  • 3
  • 35
  • 48