Git clone using access token

Sriram's Avatar

Sriram

30 Sep, 2015 02:45 AM

Hi,

I am trying to clone a repo using secure personal access token. But the cloning failed.

How do I clone a repo using secure personal access token? Below is the git clone I tried to use.

git config --global user.name $env:APPVEYOR_REPO_COMMIT_AUTHOR
      git config --global credential.helper store
      Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):x-oauth-basic@github.com`n"
       git clone https://repoName:xZfJWIsA3MM8aPUw2wx2tqvgwzwTIa9JNGNCL5GhEH+NyNoktjHWzxO/mGBrioyz@github.com/repoName/Test.git
     
The actual issue is , I need to clone a private repo during a build and push the contents. I can directly use my access token (instead of encrypting it), but I cannot add access token to a public yml file.

Any help on this will be really useful.

  1. Support Staff 1 Posted by Feodor Fitsner on 30 Sep, 2015 04:42 AM

    Feodor Fitsner's Avatar

    How did it fail? What error do you get?

  2. 2 Posted by Sriram on 30 Sep, 2015 01:50 PM

    Sriram's Avatar

    Authentication failed. i suspect the "/" in encrypted value.
    I tried these below options. But I got the same error.
    git clone https://repoName:$($env:access_token)@github.com/repoName/Test.git

    git clone https://repoName:$($env:access_token) : x-oauth-baisc@github.com/repoName/Test.git

    please help !

  3. 3 Posted by Sriram on 30 Sep, 2015 03:09 PM

    Sriram's Avatar

    Do I need to update the project to say "allow secure variables for PRs" ?

  4. Support Staff 4 Posted by Feodor Fitsner on 30 Sep, 2015 03:17 PM

    Feodor Fitsner's Avatar

    If the clone command you run runs in PR build then yes.

    - Feodor

  5. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:00 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac