使用令牌对GitHub进行身份验证

编程入门 行业动态 更新时间:2024-10-22 23:40:58
本文介绍了使用令牌对GitHub进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正尝试使用个人访问令牌对GitHub进行身份验证。在github的帮助文件中,它声明使用curl方法进行身份验证( help.github/articles/creating-an-access-token-for-command-line-use )。我已经尝试过,但仍然无法推送到GitHub。请注意,我试图从未认证的服务器(Travis-CI)推送。

config --global user.emailemailaddress@yahoo git config --global user.nameusername curl -u用户名:< MYTOKEN> github/username/ol3-1.git git clone --branch = gh-pages github/username/ol3-1.git gh-pages cd gh-pages mkdir buildtest cd buildtest touch asdf.asdf git add -f。 git commit -mTravis build $ TRAVIS_BUILD_NUMBER push to gh-pages git push -fq origin gh-pages

这段代码会导致错误:

remote:匿名访问scuzzlebuzzle / ol3-1.git拒绝。

致命:< https://认证失败github/scuzzlebuzzle/ol3-1.git/ '

谢谢

curl 命令是完全错误的,您应该使用以下命令: $ b $ b

curl -H'Authorization:token< MYTOKEN>'...

除此之外,它并不授权您的计算机克隆存储库,但实际上它是私有的(但是,请注意,它不是)。 do是以下内容:

git clone https:// scuzzlebuzzle:< MYTOKEN> ; @ github / scuzzlebuzzle / ol3-1.git --branch = gh-pages gh-pages

这会将您的凭据添加到克隆存储库时创建的远程。然而,不幸的是,你无法控制Travis如何克隆你的仓库,所以你必须像这样编辑远程。

#克隆后 cd gh-pages git remote rm origin git remote add origin https:// scuzzlebuzzle:< MYTOKEN> @ github / scuzzlebuzzle / ol3-1.git

这将修复您的项目以使用内置凭证的远程计算机。

I am trying to authenticate with GitHub using a personal access token. In the help files at github, it states to use the curl method to authenticate (help.github/articles/creating-an-access-token-for-command-line-use). I have tried this, but still I cannot push to GitHub. Please note, I am trying to push from an unauthenticated server (Travis-CI).

cd $HOME git config --global user.email "emailaddress@yahoo" git config --global user.name "username" curl -u "username:<MYTOKEN>" github/username/ol3-1.git git clone --branch=gh-pages github/username/ol3-1.git gh-pages cd gh-pages mkdir buildtest cd buildtest touch asdf.asdf git add -f . git commit -m "Travis build $TRAVIS_BUILD_NUMBER pushed to gh-pages" git push -fq origin gh-pages

This code causes the errors:

remote: Anonymous access to scuzzlebuzzle/ol3-1.git denied.

fatal: Authentication failed for 'github/scuzzlebuzzle/ol3-1.git/'"

Thanks

解决方案

Your curl command is entirely wrong. You should be using the following

curl -H 'Authorization: token <MYTOKEN>' ...

That aside, that doesn't authorize your computer to clone the repository if in fact it is private. (Taking a look, however, indicates that it is not.) What you would normally do is the following:

git clone scuzzlebuzzle:<MYTOKEN>@github/scuzzlebuzzle/ol3-1.git --branch=gh-pages gh-pages

That will add your credentials to the remote created when cloning the repository. Unfortunately, however, you have no control over how Travis clones your repository, so you have to edit the remote like so.

# After cloning cd gh-pages git remote rm origin git remote add origin scuzzlebuzzle:<MYTOKEN>@github/scuzzlebuzzle/ol3-1.git

That will fix your project to use a remote with credentials built in.

更多推荐

使用令牌对GitHub进行身份验证

本文发布于:2023-11-03 16:20:50,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:令牌   身份验证   GitHub

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!