Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法设置GitHub访问令牌_Git_Github - Fatal编程技术网

无法设置GitHub访问令牌

无法设置GitHub访问令牌,git,github,Git,Github,当我尝试使用HTTPS和git克隆任何存储库时,它不会提示我输入访问令牌,我只得到一个403错误。使用SSH的git克隆工作正常。我怀疑问题与使用ZScaler的公司笔记本电脑有关,HTTPS信任\证书链已断开。 git如何像浏览器一样知道要使用什么证书?或者我如何解决这个问题 $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git Cloning into 'python-docs-samples'.

当我尝试使用HTTPS和git克隆任何存储库时,它不会提示我输入访问令牌,我只得到一个403错误。使用SSH的git克隆工作正常。我怀疑问题与使用ZScaler的公司笔记本电脑有关,HTTPS信任\证书链已断开。
git如何像浏览器一样知道要使用什么证书?或者我如何解决这个问题

$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
Cloning into 'python-docs-samples'...
fatal: unable to access 'https://github.com/GoogleCloudPlatform/python-docs-samples.git/': The requested URL returned error: 403
我已尝试从我的钥匙链中删除所有引用,因此它将再次提示我输入访问令牌,但从未这样做。另外,我在OSX密钥链中看不到任何对git的引用

我的本地git设置为使用osx密钥链

$ git config --get-all --show-origin credential.helper
file:/Applications/Xcode-11.3.1.app/Contents/Developer/usr/share/git-core/gitconfig     osxkeychain
但它似乎知道我在公司GitHub的GitHub证书

$ git credential-osxkeychain get

password=<my company password>
username=<my company logon>
现在这个命令不返回任何内容

$ git credential-osxkeychain get
但是仍然会出现403错误,即使按照下面的建议使用我的GitHub用户名,也不会提示我。

我已经仔细检查了我的钥匙链,但没有为GitHub存储任何信息

鼓励凭证帮助者使用正确的登录请求您的凭证的一个好提示是将所述登录添加到您的GitHub URL:

 git clone https://<MyGitHubAccount>@github.com/GoogleCloudPlatform/python-docs-samples.git
git clone https://@github.com/GoogleCloudPlatform/python-docs-samples.git
确保你


然后它会提示您输入密码。

终于找到了解决方案

$ git config --global url.git://github.com.insteadOf "https://github.com"

这将强制公共github站点使用git协议而不进行身份验证,同时仍在公司网络和我们的私有github存储库中工作

这对您有帮助吗?不走运,我尝试了一些变体,但仍然是相同的行为重置您的帮助者:
git config--global credential.helper osxkeychain
尝试过,git仍然不会提示我使用
git\u CURL\u VERBOSE=1 git\u TRACE\u REDACT=0运行passwordTry,并查看您是否确实在
Authorization
标题中发送凭据(但如果在此处发布,请忽略该标题的内容)。您可以对该标题的内容进行Base64解码,以查看使用了哪些creds。这没有太大帮助,但有一些进展,我在问题中添加了一个未加密的连接,这意味着任何有足够动机的人都可以篡改您的数据。您最好使用SSHURL(例如,
URL)。ssh://git@改为github.com,而不是
)。
$ git config --global url.git://github.com.insteadOf "https://github.com"