Connect Power BI to a Private GitHub Repo

Recently, I had a client who wanted me to connect their Power BI dashboard to a .csv file hosted in their private GitHub repository. There are many examples out there on how to connect to a public repository. In fact, if you’re one of the many Power BI Developers that created a COVID dashboard, you may be familiar with how to do this.

However, I could not find any information on how to connect to a private repo and it’s not very intuitive right off the bat. But it’s actually easy once you figure it out. It’s almost the same process as connecting to a public repo; the only difference is how you authenticate. Establishing a connection to a public repo only requires an anonymous authentication using Power BI’s Web connector.

Anonymous authentication when connecting to public GitHub repo.

GitHub Personal Access Token

After an hour of searching and reading through many useless forum posts, I finally opened GitHub’s API documentation and looked for something useful. Then I started reading about authenticating with the API – I knew there had to be a way to authenticate using Power BI.

Ways to authenticate with the API.

The first step is to create a personal access token in GitHub. Make sure you have your personal access token stored somewhere safe. Once you have done that, the rest is easy. As soon as I read the following message, I immediately knew what to do in Power BI:

The personal access token is used as part of the authentication.

Connect Power BI to GitHub Repo

To connect to your .csv file in GitHub, go to Power BI, click on Get data and select the Web connector. Paste in the URL that points to the raw .csv file in your GitHub repo and select the OK button. If you do not know how to find the raw .csv file URL, there is documentation and tutorials out there (e.g., COVID-19 Dashboard by Datachant and many others).

Use the GitHub raw file URL.

The authentication screen will pop up and ask how you want to access web content. Use the Basic authentication method. Make sure you have the proper URL level selected in the dropdown. In my situation, I chose the level that represents the repo, because anything in this repo is private, but I may have other repos that are public and I don’t want the authentication settings to affect how I connect to other repos. In the User name field type the email address associated with the GitHub account where the private repo lives. In the Password field paste in the personal access token from GitHub. Click on the Connect button.

Use GitHub account user name and personal access token for Basic authentication.

Now that you have successfully connected to your .csv file, you can any transformations needed before loading the data model. That’s it!

Conclusion

Connecting Power BI to a private GitHub repo is super easy. The key differences are:

  • Use the basic authentication method instead of anonymous.

  • Use the GitHub account email as the user name.

  • Use the personal access token as the password.

Previous
Previous

Create a Custom Focus Mode to Keep Color Backgrounds Visible

Next
Next

Filter Power BI Report by 2 Date/Time Ranges