当 composer 连接到 GitHub 时,我收到一条关于弃用身份验证方法的警告。我应该使用什么身份验证配置?

When composer connects to GitHub I receive a warning about a deprecation authentication method. What authentication configuration should I use?

GitHub 已开始发送有关已弃用身份验证的电子邮件,但我还没有找到详细说明作曲家 auth.json 在新制度下应该是什么样子的资源。

我的要求相对简单 - 使用 composer 更新开发中的 Symfony 应用程序,偶尔尝试其他 repos。

有了这个,我原来的配置(自动构建)...

{
    "github-oauth": {
        "github.com": "(a string)"
    }
}

...我收到此警告:

...your personal access token...was used as part of a query parameter to access an endpoint through the GitHub API...Please use the Authorization HTTP header instead...

但是当我尝试使用其他配置时:

{
    "http-basic": {
        "github.com": {
            "username": " my email address",
            "password": " my password "
        }    }
}

我收到另一个警告:

You recently used a password to access an endpoint through the GitHub API using Composer/1.9.1 ...We recommend using a personal access token (PAT) with the appropriate scope to access this endpoint instead.

它到底应该是什么样子,为什么我会收到这些弃用警告?

这两个配置中,第一个是正确的。

"string" 应该是您的个人访问令牌 (PAT),在 GitHub 上配置了 appropriate access scopes

要为您的令牌配置范围,您需要访问您的 GitHub 开发人员设置 -> Personal Access Tokens

第二种格式尝试通过发送您的用户名和密码而不是生成的令牌来进行身份验证。这是一种糟糕的安全做法,不应这样做。

但您收到第一个警告的主要原因是 您是 运行 旧作曲家版本

您需要更新到 1.9.3 版本where this was fixed。在以前的版本中,由于 composer 连接到 GitHub.

的方式,您可能会收到弃用警告

更新作曲家,错误将消失

php composer.phar self-update

composer self-update