Cloning private repo with a Github App private key

Hello!

I was wondering if it is possible to clone a private repository using a Github App private key.

Is it possible?

If so, do you know which permissions it requires to do so?

I tried giving it “Contents” read-only permissions, but it still cannot clone it…

The way I test it is by using:

ssh-agent bash -c 'ssh-add {{private_key_file.pem}}; git clone git@github.com:{{username}}/{{repo}}.git'

Did you find a solution?

I am trying to clone private repositories with my Github App aswell.

I just found a way that works for me using the command line.

https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/ at the very bottom

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

I am retrieving a user token using a POST request to https://api.github.com/app/installations/$installationId/access_tokens.

2 Likes