带有 oauth 访问令牌的 Github 克隆 [英] Github clone with oauth access token

查看:29
本文介绍了带有 oauth 访问令牌的 Github 克隆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在脚本中,我尝试使用 oauth 令牌克隆 Github 存储库.

Inside a script I am trying to clone a Github repository with an oauth token.

根据本教程:

https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth

我应该能够像这样为它构建一个命令:

I should be able to build a command for it like this:

git clone https://<token>@github.com/owner/repo.git

如果我使用适当的访问令牌手动尝试此操作,它仍会要求我输入密码.

If I try this manually with a proper access token, it still asks for my password.

如果我在命令行上尝试,我只会收到 repository not found 错误.

If I try it on the commandline I am simply getting a repository not found error.

这篇文章是 2012 年的,我找不到任何相关的 API 文档.所以我想知道这是否仍然有效.

The article is from 2012 and I cannot find any API documentation for this. So I am wondering if this still works.

推荐答案

我原来是一个范围问题.我当然需要完整的 repo 范围,因为我试图克隆一个 private 存储库.

I turned out to be a scope issue. I of course needed full repo scope since I was trying to clone a private repository.

遗憾的是,Github 没有针对此类事情提供更清晰的错误消息,但出于安全考虑,我理解原因.

It's a shame Github does not have some clearer error messages for these kind of things, but security wise I understand why.

对于在尝试这样的事情时试图找出问题所在的任何人,我建议创建一个可以完全访问所有内容的个人访问令牌:

For anyone trying to figure out what is wrong when trying out something like this, I would suggest to create a personal access token with full access to everything:

设置 > 开发者设置 > 个人访问令牌 > 生成新令牌

settings > developer settings > personal access tokens > generate new token

通过这种方式,您可以通过将您的令牌与具有所有访问权限的个人访问令牌进行比较来轻松测试它是否是范围问题.

This way you can easily test if it is a scope issue by comparing your token with a personal access token that has access rights for everything.

感谢仍然花时间阅读本文的任何人.

Thanks for anyone who still took the time to read this.

这篇关于带有 oauth 访问令牌的 Github 克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆