我使用curl
在GitHub.com账户上创建仓库时遇到了问题(没有ssh)。
我使用Jekyll创建了一个基本的静态本地站点,我想将其推送到GitHub.com仓库(我想将该站点托管在<username>.github.io
上,并根据GitHub页面上的说明,该仓库必须与包含本地站点的文件夹同名。
我为GitHub登录启用了双重身份验证,因此按照此帖子的指示,在请求头中使用选项-H "X-GitHub-OTP":<token>
传递一个OTP /令牌(在应用程序设置中生成)。 我可以登录(此前此帖子曾提出Github登录不起作用的问题,原因是未正确关闭字符串"X-GitHub-OTP"
),但现在登录成功后我收到一个400代码的响应。 这是我使用的curl
命令:
$username="<username>"
$reponame="$username.github.io"
$token="<token>"
$apidom="https://api.github.com/user/repos/"
$curl -u $username -H '{"X-GitHub-OTPOTP":$token}' -d '{"name":$reponame,"description":$repodesc}' $apidom
以及响应消息:
<p><strong>We didn't receive a proper request from your browser.</strong></p>
<p>Sorry about that. Please try refreshing and contact us if the problem persists.</p>
<div id="suggestions">
<a href="https://github.com/contact">Contact Support</a> —
<a href="https://status.github.com">GitHub Status</a> —
<a href="https://twitter.com/githubstatus">@githubstatus</a>
</div>
{ "message": "必须指定双因素身份验证OTP代码。", "documentation_url": "https://developer.github.com/v3/auth#working-with-two-factor-authentication" }
- user997225curl
和-H '{"X-GitHub-OTPOTP":$token}
在头部发送OTP代码。 我存储的HTTP响应表明浏览器未正确形成请求,但正如您从上面的会话输出中看到的那样,我正在按照您建议的方式进行操作,参见此处。 - user997225curl
吗? - Chris