Today, I try to do Laravel install by running composer create-project laravel/laravel=5.1.* myproject --prefer-dist
and I get this error:
Could not fetch https://api.github.com/repos/laravel/laravel/zipball/716e65268ae123e5bd73e505acf9695c678aff88, 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+MyPC+2016-02-19+0343 to retrieve a token. It will be stored in "C:/Users/MyPC/AppData/Roaming/Composer/auth.json" for future use by Composer.
Why am I unable to fetch from GitHub? This is the first time I am facing this after years of using. Is there any policy change by GitHub?
The accepted answer of Niels is correct. To use the generated token in composer use the command:
composer config -g github-oauth.github.com YOUR_TOKEN
This policy has been active at Github a long time regrettably. It is documented here and you can see your current status at https://api.github.com/rate_limit in the core
section.
Also see https://developer.github.com/v3/#rate-limiting:
For unauthenticated requests, the rate limit allows you to make up to 60 requests per hour. Unauthenticated requests are associated with your IP address, and not the user making requests.
There is nothing Composer can do to circumvent that, hence why it throws the verbose error:
Create a GitHub OAuth token to go over the API rate limit
You can do this at https://github.com/settings/tokens, and it needs to be done only once per installation as Composer remembers the token for subsequent requests.
2022 Update for Composer 2.x
I tried the other solutions listed here and they didn't work for me. Inspecting the verbose output of composer update
I found that you can set the github.accesstoken
configuration option using git
and Composer will use that.
git config --global github.accesstoken <token>
, replacing <token>
with the token from above.You can remove the --global
option if you want to set the token specifically for your current project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With