Authenticate with GitHub using a token

后端 未结 10 560
广开言路
广开言路 2020-11-30 17:09

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 (https://help.github.com

10条回答
  •  鱼传尺愫
    2020-11-30 17:27

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

    curl -H 'Authorization: token ' ...
    

    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 https://scuzzlebuzzle:@github.com/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 set-url origin https://scuzzlebuzzle:@github.com/scuzzlebuzzle/ol3-1.git
    

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

    Warning: Tokens have read/write access and should be treated like passwords. If you enter your token into the clone URL when cloning or adding a remote, Git writes it to your .git/config file in plain text, which is a security risk.

提交回复
热议问题