Github克隆与OAuth访问令牌

Github克隆与OAuth访问令牌

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

问题描述

在脚本中,我试图使用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:

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

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.

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

08-11 12:59