title: Cloning a private GitHub repo, authenticated as a GitHub app
body: <p>I'm building a CI application that does some work on the contents of a GitHub repo on a schedule, or every time new code is merged, via a Webhook.</p>
  
  <p>I've created a GitHub app and got everything set up so users can sign in with it, grant it access to their repos, and configure their CI jobs.</p>
  
  <p>I'm unable to find documentation on how to clone the full repo contents, if it is private, by authenticating as the user who connected my GitHub app. I found the <a href="https://developer.github.com/v3/git/trees/#get-a-tree" rel="noreferrer">docs on getting the tree for a repo</a> but it seems like I'd still have to go through that JSON response and download every file separately, which feels like re-implementing Git clone myself.</p>
  
  <p>Right now I'm just launching the <code>git clone</code> command as a subprocess from my CI script. Just wondering what the solution is here. Should I use libgit2? Or use that tree API and download all the files?</p>