Forum Discussion

Copycat's avatar
Copycat
Frequent Visitor
11 months ago
Solved

Download commits, commiter data from GitHub to PowerBI

Good day,

 

Technical:

My team and myself are pushing our .pbip files to company GitHub, each saved in its own folder.

 

Scope:

I want to create a table, which then will be replicated for each report so user can see a changelog. 

The changelog should show: commit message | commiter ID | commit date | report name.

 

Current solution:

I was able to achieve all of it with below code:


Auth: Basic

let
    Owner = "git-owner",
    Repo = "git-repo",
    Branch = "pbi-reports",
    
    BaseUrl = "https://github.contosco.com/api/v3/repos/" & Owner & "/" & Repo & "/commits",
    
    Source = Json.Document(Web.Contents(BaseUrl, [Query = [sha = Branch, per_page = "100"]])),
    ToTable = Table.FromRecords(Source),
    
    AddFilesList = Table.AddColumn(ToTable, "Files", each 
        let
            CommitUrl = "https://github.contosco.com/api/v3/repos/" & Owner & "/" & Repo & "/commits/" & [sha],
            CommitDetails = Json.Document(Web.Contents(CommitUrl)),
            Files = CommitDetails[files]
        in
            Files
    )

 

Locally, everything is working perfectly.

 

Issue:

When I upload it to powerbi.com, I receive below error message during refresh:

Data source error{"error":{"code":"DMTS_OAuthFailedToGetResourceIdError","pbi.error":{"code":"DMTS_OAuthFailedToGetResourceIdError","details":[{"code":"DM_ErrorDetailNameCode_UnderlyingErrorMessage","detail":{"type":1,"value":"Failed to get OAuth resource, please make sure the OAuth is supported"}}],"exceptionCulprit":1}}}

 

So I have tried to pass PAT within the M code e.g,:

Source = Json.Document(Web.Contents(BaseUrl,
        [
            Query = [sha = Branch, per_page = "100"],
            Headers = [Authorization="Bearer PAT_TOKEN_IS_HERE"]
        ]))

But this failed as well.

 

Question:
Is there a solution to download all of the data I need without modifying the gateway or putting company data at risk?

I don't remember now what I did but I also received error about dynamic data sources - which was a new error, some progress, but I was not able to resolve it either.

 

Edit:

I also tried to use beta GitHub connector (PowerBI > Get Data) but I was not able to login since it was asking for credentials and combination of email/login and PAT (instead of password) did not work.

 

 

  • Hii Copycat 

     

    Since you're using GitHub Enterprise with SSO, the Power BI GitHub connector will not work  it only supports public github.com using GitHub’s own OAuth app. Enterprise SSO logins, enterprise domains (github.company.com), and PAT-based auth are not supported in the connector, so your use case cannot refresh in Power BI Service.

    The working alternatives is :

     Power Automate >> connect to GitHub Enterprise using SSO >> save commits/JSON to SharePoint/Blob >. Power BI refreshes from there.

     

7 Replies

  • Hii Copycat 

     

     

    Your M code works locally but cannot refresh in Power BI Service because GitHub REST API requires OAuth, and Power BI Service only supports that through the GitHub connector, not custom M.

    To fix:
    Use the GitHub connector
    or
    Use Power Automate / Azure automation to store the data first

     

    • Copycat's avatar
      Copycat
      Frequent Visitor

      How can I use GitHub connector?
      When I select it via Get Data -> GitHub, I provide 'owner' and 'repo name' it opens browser and asks me to log in.

      As I mention before I have tried below combinations (login | password):
      company_email | PAT
      company_id | PAT
      PAT | no password required

       

      My PAT setup is: admin:org, repo, user, workflow

      • rohit1991's avatar
        rohit1991
        Icon for Super User rankSuper User

        Hii Copycat 

         

        You can connect using below steps :

        1. Power BI Desktop >> Get Data >> GitHub
        2. Enter:
          • Owner = org or user name
          • Repository = repo name
        3. When the browser opens >> log in with your normal GitHub account
        4. GitHub will ask permission:
          • “Power BI wants to access your GitHub data”
        5. Click Authorize
        6. Power BI retrieves an OAuth token automatically

        There is no need of PAT or Password.

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Copycat 

    Thank you for reaching out to the Microsoft Fabric Forum Community.

    rohit1991 Thanks for the inputs.

    I hope the information provided by user was helpful. If you still have questions, please don't hesitate to reach out to the community.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Copycat 

      Hope everything’s going smoothly on your end. I wanted to check if the issue got sorted. if you have any other issues please reach community.