尝试使用 GitHub 挂钩代码管道时出现 401 错误凭据

Yan*_*Liu 5 amazon-web-services aws-codepipeline

我在尝试执行以下操作时收到此错误消息cdk deploy PipelineStack

Webhook could not be registered with GitHub. Error cause: Invalid credentials [StatusCode: 401, 
Body: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}] 
(Service: AWSCodePipeline; Status Code: 400; Error Code: ValidationException; 
Request ID: dbab7e3e-ed28-42b8-a2d5-7539be32776b; Proxy: null)
Run Code Online (Sandbox Code Playgroud)

为什么我会看到上述错误?

我什至尝试直接验证存储在AWS秘密管理器中的令牌

curl -H "Authorization: token token-stored-in-secretManager" https://api.github.com/users/my-user
Run Code Online (Sandbox Code Playgroud)

并返回200响应。

我的问题类似于How to connect github repo with aws using cdk?

顺便说一句,我的 github 存储库设置为私有而不是公开。不确定这是否重要。

语境

这是我的源代码阶段的 CDK 代码。

Webhook could not be registered with GitHub. Error cause: Invalid credentials [StatusCode: 401, 
Body: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}] 
(Service: AWSCodePipeline; Status Code: 400; Error Code: ValidationException; 
Request ID: dbab7e3e-ed28-42b8-a2d5-7539be32776b; Proxy: null)
Run Code Online (Sandbox Code Playgroud)

这是我的个人访问令牌权限:

在此输入图像描述

Yan*_*Liu 7

我的错。

我没有正确存储令牌: 在此输入图像描述

它应该像这样存储:

在此输入图像描述