composer / composer

Dependency Manager for PHP
https://getcomposer.org/
MIT License
28.62k stars 4.55k forks source link

[SUPPORT]: Could not fetch X, please review your configured GitHub OAuth token or enter a new one to access private repos #11991

Open adriafigueres opened 5 months ago

adriafigueres commented 5 months ago

Hi,

I have created a public repository called native-push-notifier-bundle 2 days ago and I’m trying to implement the package in a private repo running composer update and I am having the following error:

Could not fetch https://api.github.com/repos/m10c/native-push-notifier-bundle/zipball/4adf5a775176fd5d80f1a933e0541c2716bd6e90, please review your configured GitHub OAuth token or enter a new one to access private repos
When working with _public_ GitHub repositories only, head to https://github.com/settings/tokens/new?scopes=&description=Composer+on+Adrias-MacBook-Air.local+2024-05-28+0835 to retrieve a token.
This token will have read-only permission for public information only.
When you need to access _private_ GitHub repositories as well, go to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+Adrias-MacBook-Air.local+2024-05-28+0835
Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.
Tokens will be stored in plain text in "/Users/adriafigueres/.composer/auth.json" for future use by Composer.
For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth

I’ve tried:

Regenerating the API token and pasting it when prompted; Adding the new token via composer config --global --auth github-oauth.github.com ; Adding the new token by editing ~/.composer/auth.json manually;

But none worked. I've checked in packagist, and the repo actually exists: https://packagist.org/packages/m10c/native-push-notifier-bundle

Any suggestions? Thanks

rodber commented 5 months ago

I was able to install m10c/native-push-notifier-bundle package, but I'm getting the exact same issue (403) with another package. I tried creating new tokens, clearing composer cache, etc. Also my token usage has not reached any limit yet and of course that the package is public.

I tried on a brand new VPS, with and without the GitHub token and it works as expected. No issues at all.

This issue seems to be related to the machine/network being used, most likely a cache which is not handled by composer clear-cache. The only useful trait I was able to detect is that the issue goes away if you:

  1. Locate your composer path with composer config --list --global | grep home
  2. Remove your GitHub auth at auth.json (remove the whole "github-oauth" property)
  3. Go back to your project and run composer update
  4. Re-enable the GitHub auth configuration (see step 2)

After doing these steps the "jamming" stops happening in my systems.

sumonst21 commented 3 months ago

I was able to install m10c/native-push-notifier-bundle package, but I'm getting the exact same issue (403) with another package. I tried creating new tokens, clearing composer cache, etc. Also my token usage has not reached any limit yet and of course that the package is public.

I tried on a brand new VPS, with and without the GitHub token and it works as expected. No issues at all.

This issue seems to be related to the machine/network being used, most likely a cache which is not handled by composer clear-cache. The only useful trait I was able to detect is that the issue goes away if you:

  1. Locate your composer path with composer config --list --global | grep home
  2. Remove your GitHub auth at auth.json (remove the whole "github-oauth" property)
  3. Go back to your project and run composer update
  4. Re-enable the GitHub auth configuration (see step 2)

After doing these steps the "jamming" stops happening in my systems.

I experianced this issue for the first time but removing the "github-oauth" following the first step to find out the path did the trick. everything working fine again. :)