Could not fetch [repository], please review your configured GitHub OAuth token when running "composer update"

Could not fetch [repository], please review your configured GitHub OAuth token when running "composer update"

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Could not fetch [repository], please review your configured GitHub OAuth token when running "composer update"

When composer update fails with an error stating it could not fetch a specific repository from the GitHub API, the immediate instinct is often to generate a new OAuth token and reconfigure Composer. However, simply generating a fresh token at https://github.com/settings/tokens/new and piping it into the global config via composer config --global github-oauth.github.com [token] does not guarantee success if the underlying authentication context remains misaligned with GitHub's current requirements.

This error message specifically references the GitHub API endpoint for fetching zipballs of repositories. Composer relies on this API to download package archives. If your environment is attempting to access private repositories or if the public token you possess has expired or been revoked, the API will reject the request. The solution involves verifying that the token you are providing matches the scopes required by the current Composer version and ensuring that no stale configuration is overriding your new credentials.

Verifying Token Scopes and Expiration

The most common pitfall occurs when a developer generates a token with insufficient permissions or an expired lifespan. While https://github.com/settings/tokens/new allows you to generate tokens, the default scope for "public GitHub repositories only" is often minimal. If your project dependencies include private packages, a public-only token will fail immediately, regardless of how recently it was created.

To resolve this, navigate to the token generation page and ensure the following:

  1. Expiration Date: Set an expiration date far in the future (e.g., never) to avoid accidental lockouts caused by GitHub's automatic token rotation or expiration policies.
  2. Scopes: Although public repositories generally do not require read-only access, it is best practice to explicitly grant repo scope if you intend to ever access private data, even if your current setup only uses public packages. This future-proofs the configuration against dependency updates that might pull in private libraries.

After generating the token, copy the raw value (without quotes) and apply it using the global config command:

composer config --global github-oauth.github.com "{YOUR_NEW_TOKEN}"

Note: Ensure you replace {YOUR_NEW_TOKEN} with the actual string generated by GitHub.

Clearing Stale Configuration

A frequent reason why a new token appears to be rejected is that Composer retains a stale configuration entry. If you previously configured a different token or an invalid placeholder, simply adding a new one does not remove the old entry from config.json. You must explicitly clear the existing global GitHub OAuth setting before applying the new credentials.

Run the following command to remove any existing global GitHub OAuth configuration:

composer config --global --delete github-oauth.github.com

Once the stale entry is removed, apply your newly generated token again. This two-step process—deleting the old config and writing the new one—is critical for ensuring that Composer reads the most recent authentication state without ambiguity.

Alternative Authentication Strategies

If configuring a global OAuth token proves cumbersome or if you are working within a corporate environment where API keys should not be stored in plain text, consider using composer.json for repository-specific overrides or leveraging an .env file for local development.

For instance, you can define the token in your project's root .env file and load it dynamically:

COMPOSER_GITHUB_OAUTH_GITHUB_COM="your_token_here"

Then, reference this environment variable when configuring Composer locally rather than hardcoding the token globally. This approach limits the exposure of credentials to the specific machine where the project is being developed, which is a significant security trade-off compared to global configuration.

Final Verification

Once the configuration has been updated and stale entries cleared, clear your Composer cache to ensure no cached metadata interferes with the new authentication flow:

composer clear-cache

Run composer update again. If the error persists, check the Composer version. Newer versions of Composer (1.0+) have stricter API requirements compared to legacy versions (0.6+). If you are using a very old Composer version that does not support OAuth tokens natively, upgrading via composer self-update is often the most effective fix, as it aligns your tooling with GitHub's current authentication standards.

Our network