无法获取 [存储库],请在运行“composer update”时检查您配置的 GitHub OAuth 令牌

Mey*_*sam 18 php github-api composer-php

当我运行时composer update,出现以下错误:

无法获取https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf,请检查您配置的 GitHub OAuth 令牌或输入新的令牌以访问私有存储库。仅使用公共 GitHub 存储库时,请前往https://github.com/settings/tokens/new?scopes=&description=Composer以检索令牌。

然后我转到“https://github.com/settings/tokens/new”,生成一个新令牌并使用以下命令设置它:

composer config --global github-oauth.github.com [token]
Run Code Online (Sandbox Code Playgroud)

即使在那之后,当我运行时composer update我也会遇到同样的错误。我怎样才能解决这个问题?

Sha*_*dek 14

--auth命令中缺少您。命令应该是:

composer config --global --auth github-oauth.github.com [token]
Run Code Online (Sandbox Code Playgroud)


小智 7

我刚刚遇到了同样的问题,这是由于我的auth.json文件中的凭据不正确造成的。两个建议:

  • auth.json按照文档中的描述在文件中定义正确的凭据:
{
    "http-basic": {
        "example.org": {
            "username": "username",
            "password": "password"
        }
    },
    "github-oauth": {
        "github.com": "ghp_your_token_here"
    }
}
Run Code Online (Sandbox Code Playgroud)
  • 或者,如果您不需要此文件,只需删除该auth.json文件即可。

希望这有帮助!

  • 删除 json 文件后,它对我有用。谢谢 (3认同)