New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer Update Fails due to Github Authorization #3542

Closed
fiatux opened this Issue Dec 12, 2014 · 23 comments

Comments

Projects
None yet
@fiatux

fiatux commented Dec 12, 2014

During composer update I am asked for my github credentials repeatedly. What may be causing this?

An existing OAuth token for Composer is present and will be reused

Could not fetch https://api.github.com/authorizations, enter your GitHub credentials to go over the API >rate limit
The credentials will be swapped for an OAuth token stored in /Users/[USER]/.composer/auth.json, your >password will not be stored
To revoke access to this token you can visit https://github.com/settings/applications

Yes, I am entering my password correct, I have tried several different accounts and I can get authorization from Github if I use curl from cmdline.

@hkdobrev

This comment has been minimized.

Contributor

hkdobrev commented Dec 12, 2014

@fiatux

This comment has been minimized.

fiatux commented Dec 12, 2014

Not really, solved it by creating new token and adding it to the project's composer.json. I'm not sure why the valid token on /Users/[USER]/.composer/auth.json could not be used.

@fiatux fiatux closed this Dec 12, 2014

@fonsecas72

This comment has been minimized.

Contributor

fonsecas72 commented Dec 12, 2014

I'm not sure why the valid token on /Users/[USER]/.composer/auth.json could not be used.

Maybe due to current user or COMPOSER_HOME environment variable at the time of the composer install being different of the expected?
I think I stumbled to something like that before.

@hamiltont

This comment has been minimized.

hamiltont commented Dec 19, 2014

solved it by creating new token and adding it to the project's composer.json

Could someone post the format of how to do this? I'm experiencing a similar problem and wish to solve it manually for the moment

@slier81

This comment has been minimized.

slier81 commented Dec 19, 2014

Could someone post the format of how to do this? I'm experiencing a similar problem and wish to solve it manually for the moment

Yes, i want to know too

@fonsecas72

This comment has been minimized.

Contributor

fonsecas72 commented Dec 19, 2014

You can solve it by creating a new github token to authenticate your composer requests.
You can do this two ways:

By defining your token globally:

composer config --global github-oauth.github.com <TOKEN>

Or by defining your token in a project composer.json:

{  
  "config": {
    "github-oauth": {
      "github.com": "<TOKEN>"
      }
    }
}

More information about the problem and how to generate github tokens:
Composer troubleshooting

@energysx

This comment has been minimized.

energysx commented Dec 25, 2014

hugofonseca thanks a lot!

@yoanisgil

This comment has been minimized.

yoanisgil commented Jan 2, 2015

@hugofonseca Thanks!

@Commifreak

This comment has been minimized.

Commifreak commented Jan 8, 2015

The global Token config does not work (as mentiod in Post 3):

C:\Users\robin.kluth>composer diag
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity: OK
Checking HTTP proxy: OK
Checking HTTP proxy support for request_fulluri: OK
Checking HTTPS proxy support for request_fulluri:
Could not fetch https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0, ent
er your GitHub credentials to go over the API rate limit
The credentials will be swapped for an OAuth token stored in C:/Users/robin.klut
h/AppData/Roaming/Composer/auth.json, your password will not be stored
To revoke access to this token you can visit https://github.com/settings/applica
tions
Username:

while in %appdata%\Composer\auth.json:

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

If I add the token to projects composer.json, it is working as expected.

@webdevilopers

This comment has been minimized.

webdevilopers commented Jan 15, 2015

So the solution is to put the token into the composer.json directely instead of relying on the auth.json?

Will this be solved as suggested in the latest issue #3566 @Seldaek ?

Because as Malcolm Fell @emarref mentions:
If you're working on a collaborative project, you should not commit your key in the project source control. The alternative is to set your key in your home directory...
https://coderwall.com/p/kz4egw/composer-install-github-rate-limiting-work-around

@Commifreak

This comment has been minimized.

Commifreak commented Jan 15, 2015

Hi,

I figured out, that the auto-generated token (via composer) ist not accepted. If I create the key via GitHub's WebUI and replace the old one in composer.json, it is working.

@webdevilopers

This comment has been minimized.

webdevilopers commented Jan 15, 2015

Have you tried that within the auth.json or config.json too?

@midan888

This comment has been minimized.

midan888 commented Jan 21, 2015

I generated new token on Gtihub and pasted this in ocmposer json of the project and it worked, thanks to hugofonseca
{ "config": { "github-oauth": { "github.com": "<TOKEN>" } } }

@webdevilopers

This comment has been minimized.

webdevilopers commented Jan 22, 2015

Ok, so the important point is that the token has to be added to the `composer.json' file.

The attempt with auth.son of Composer is no longer supported by the curernt GitHub API:
#3566

@webdevilopers

This comment has been minimized.

webdevilopers commented Jan 29, 2015

It looks like @Seldaek added a fix for the original issue by @fiatux :
#3651

@informaticosgb

This comment has been minimized.

informaticosgb commented May 26, 2015

Gracias fonsecas72, funciona :D

composer clear-cache

composer global require "fxp/composer-asset-plugin:1.0.0-beta4"

composer config --global github-oauth.github.com "my_token"

composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-application

Así me funcionó para Yii2 Advanced Template.

@Peter74

This comment has been minimized.

Peter74 commented Jun 21, 2015

Hi I was face same problem.
Solution for me was:

composer config --global github-oauth.github.com <TOKEN>

thanks @fonsecas72
...and as a result of it was writing token at auth.json :

{  
  "config": {
    "github-oauth": {
      "github.com": "<TOKEN>"
      }
    }
}

...but not in composer.json - that was just mistake in explanation, but if you run

composer config --global github-oauth.github.com <TOKEN>
  • you will be OK.
@marcozs84

This comment has been minimized.

marcozs84 commented Sep 3, 2015

Posted by codekman at

http://www.yiiframework.com/forum/index.php/topic/60340-issue-while-installing-yii-2/

Please see the line above the cmd, here you will find the url and visit this url and you will git the token and paste the token.

  • it worked for me at least

ralphilius added a commit to ralphilius/bitcoin-faucet-rotator that referenced this issue Jan 1, 2016

@o5

This comment has been minimized.

o5 commented Oct 20, 2016

Is possible to remove auth token via composer config -g command? I mean something like composer config -g --unset repositories.foo but for auth.json.

Sure, I can remove by fe jg but build-in support in composer should be cool.

@Seldaek

This comment has been minimized.

Member

Seldaek commented Oct 21, 2016

This will do it for example: composer config --global --auth --unset github-oauth.github.com

Canadadry added a commit to Canadadry/php-matcher that referenced this issue Nov 8, 2017

change name for posting on packagist
Need packagist since simple composer update is not possible due to composer/composer#3542
@breakline87

This comment has been minimized.

breakline87 commented Apr 16, 2018

Can you guys make something which works without extensive modifications even for a beginner?

@saxsax1995

This comment has been minimized.

saxsax1995 commented Aug 27, 2018

solved by use this cmd: composer config --global --auth github-oauth.github.com
for example : composer config --global --auth github-oauth.github.com 123456

@alenux

This comment has been minimized.

alenux commented Oct 17, 2018

solution :
just add in composer.json

"config": {
"process-timeout": 1800,
"fxp-asset": {
"enabled": false
}
},

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