clone GitHub repo with fine-grained token
Asked Answered
S

3

23

With classical Github tokens you can clone a repo like this:

git clone https://<your-token>@github.com/owner/repo.git

This doesn't work with the new fine-grained tokens.

How do you clone a GitHub repo with the new fine-grained tokens?

Schist answered 22/11, 2022 at 12:45 Comment(1)
Note that f-g PATs do not (currently) work for outside collaborators.Manipulator
S
37

When using fine-grained tokens you have to prefix the token with oauth2: user.
like this:

git clone https://oauth2:<your-fine-grained-token>@github.com/owner/repo.git

*credits to Andy's comment here

Schist answered 22/11, 2022 at 12:45 Comment(3)
Nice hint! FWIW, using my own username instead of oauth2 also works.Langton
Thanks! This worked for me: git clone https://<your-fine-grained-token>@github.com/<ownerusername>/repo.gitCuevas
Haha, I knew I added a comment on SO how to clone repo with new tokens, still every time I have to do it, I forget how to do it. This time google redirected me to this question and you can't imagine how nice it is to see the credits in such small thing. Have a good day!Pindling
A
6

It's the same for fine-grained tokens too.

git clone https://<your-token>@github.com/owner/repo.git

You need to grant Permissions Commit statuses, Contents, Pull requests and Metadata as Read to be able to Clone repositories. And the same Permissions need to the Read and Write to be able to push changes.

I wish the Github Permission names were a bit more intuitive or better organized :D It seems like most people get annoyed with which permission to give and fall back to the classic token.

Antietam answered 5/4 at 14:4 Comment(0)
U
1
git clone https://${token}@github.com/${owner}/${repo}.git
Uzial answered 13/3 at 10:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.