我正在尝试用REST重命名一个标签在Github上。我能读到标签
curl https://api.github.com/repos/adamschmideg/label-cleanup/labels/question它还能得到一个漂亮的json。
但是,当我试图按照更新Github问题标签上的文档更新它并执行以下操作时
curl \
--request PATCH \
https://api.github.com/repos/adamschmideg/label-cleanup/labels/question \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{\"name\": \"just-a-question\"}"它返回一条“未找到”的消息。它为不存在的标签返回相同的消息。
我做错什么了?
发布于 2018-12-13 14:48:41
这似乎是一个公共储存库,这意味着任何人都可以看到它的标签。
但是,更新标签是受限制的。您需要鉴证,例如将-u "username"添加到基本身份验证请求中:
curl \
-u "adamschmideg" \ # <-- Right here
--request PATCH \
https://api.github.com/repos/adamschmideg/label-cleanup/labels/question \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{\"name\": \"just-a-question\"}"如果您使用的是双因素身份验证,并且您想使用基本身份验证(如下面所示),则需要使用标头。
GitHub还支持在头文件中发送的OAuth2令牌,或者作为OAuth2参数发送,这不需要任何特殊步骤,如果您使用2FA,建议您这样做。
原因你得到的是“找不到”,而不是“请认证”,是吗?
在某些地方,需要身份验证的请求将返回
404 Not Found,而不是403 Forbidden。这是为了防止私人存储库意外泄漏给未经授权的用户。
https://stackoverflow.com/questions/53759747
复制相似问题