My PHP project has a dependency on a nice library php-sql-query-builder. However, this library has a bug. So I fork the library from it github source to my github account at https://github.com/mmuhasan/php-sql-query-builder and fix the bug in a branch named "dev-where-bug-fix". Then I updated my my project composer file as following:
....
"repositories": [
{
"type": "vcs",
"url": "https://github.com/mmuhasan/php-sql-query-builder"
}
],
"require":{
"nilportugues/sql-query-builder" : "dev-where-bug-fix"
},
....
When I run composer update
it ask for a oAuth token as follows:
Could not fetch https://api.github.com/repos/mmuhasan/php-sql-query-builder/contents/composer.json?ref=3dca30b0eaee835783fa61286a51dda425cd3838, 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+LAPTOP-056S12EK+2018-03-27+1845 to retrieve a token.
Since my fork is in public, and I want it to be public, why composer is asking token. Any help will be very much appreciated.
In the upper-right corner of any page, click your profile photo, then click Settings. In the left sidebar, click Developer settings. In the left sidebar, under Personal access tokens, click Tokens (classic). Select Generate new token, then click Generate new token (classic).
The solution is to update Composer to the latest version, which supports the new token format, as suggested by Jordi Boggiano on this tweet. "Composer 1.10. 21 and 2.0. 12 (both released April 1st) added support for the new GitHub token format."
In this authentication storage method, an auth. json file will be present in the same folder as the projects' composer. json file. You can either create and edit this file using the command line or manually edit or create it.
This has nothing to do with public vs. private GitHub repositories. You're hitting GitHub's API rate limit.
From Composer's troubleshooting guide:
API rate limit and OAuth tokens
Because of GitHub's rate limits on their API it can happen that Composer prompts for authentication asking your username and password so it can go ahead with its work.
If you would prefer not to provide your GitHub credentials to Composer you can manually create a token using the following procedure:
- Create an OAuth token on GitHub. Read more on this.
- Add it to the configuration running
composer config -g github-oauth.github.com <oauthtoken>
Now Composer should install/update without asking for authentication.
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