Getting CSV file from private repo in Github

This seems like a simple use case, but trying to directly import a csv file in a private Github repo. I read the Secrets documentation regarding a Personal Access Token, but I don’t really understand how to access the data directly and assign it to a variable, for example.

Is there a notebook that anyone could point to that demonstrates how to do this? I get 404 errors meaning the authentication isn’t happening. Trying undefined && Secret("GITHUB_ACCESS_TOKEN"), and it returns “undefined” which is expected behavior to obfuscate the PAT, but it’s not clear to me how a fetch or using the d3.csv() function actually sends that secret to authenticate.

Sup @nyc-tinker. Here’s an example for you:

You may have also seen this notebook? Maybe that’s where you saw the undefined && Secret("GITHUB_ACCESS_TOKEN") thing. I actually just edited it to simplify it a little.

Previously (you can see the old version here) it imported from this other notebook which has a fetchGithub function, which calls fetchGithubResponse, which calls fetch and passes in headers including the Secret.

In the simplified version, I just include the fetchGithub function in the notebook. You can see how it passes the Secret in: we pass

authorization: `token ${Secret("GITHUB_ACCESS_TOKEN")}`

in the headers of the fetch request. (fetch is the browser-standard function that d3.csv uses behind-the-scenes.) That notebook assumes the response is JSON, so my example for you builds on that to fetch a CSV.

1 Like