Search code examples
githubgithub-pages

How to fetch information from a private repo GitHub


I have a GitHub Pages site. I have a scenario in which I need to get some information that is not public. Is it possible to have the site fetch some information from a private repo and then use that information in some way? Thanks!


Solution

  • There is no secure way to use a GitHub Pages site to perform any action that requires authorization unless you get that authorization from the user of the site. That's because GitHub Pages hosts only static sites; that is, sites that contain only HTML, CSS, and JavaScript. There's no backend to store secrets that would be needed to perform authorization or tasks and it would be insecure to embed those secrets in the HTML or JavaScript of the site, since anyone could extract them.

    If you need to access a private repository, you'll need to create your own site with a suitable backend implementation (e.g., a Sinatra app) and use that to access the data on behalf of the user.