当使用授权令牌创建存储库“坏凭据”时,git返回401
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了当使用授权令牌创建存储库“坏凭据”时,git返回401相关的知识,希望对你有一定的参考价值。
当我使用跟随
curl -i -H 'Authorization: token mytoken' https://api.github.com/user/repos -d '{"name":"REPO2"}'
返回
HTTP/1.1 401 Unauthorized
Server: GitHub.com
Date: Sat, 04 Mar 2017 16:21:13 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 93
Status: 401 Unauthorized
X-GitHub-Media-Type: github.v3; format=json
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 1488646926
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Allow-Origin: *
Content-Security-Policy: default-src 'none'
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
X-GitHub-Request-Id: C3B1:3287:955066:BB6710:58BAE978
{
"message": "Bad credentials",
"documentation_url": "https://developer.github.com/v3"
}
请帮我
答案
你可以在personal access token中创建一个Settings > Developer settings > Personal access tokens
并选择repo
范围:
然后在您的请求中替换它:
curl -H 'Authorization: token {0123456789zeaz1224334534}' https://api.github.com/{user}/repos -d '{"name":"REPO2"}'
以上是关于当使用授权令牌创建存储库“坏凭据”时,git返回401的主要内容,如果未能解决你的问题,请参考以下文章
使用 PyPi 通过 git clone 传递令牌的正确方法是啥?