Forum Discussion

ayush's avatar
ayush
Frequent Visitor
7 years ago
Solved

M Language code to connect Google Analytics api directly to Power BI

This program is written on M# language and it is used for retrieving data from Google Analytics API directly to Power BI                           

Here is the link of Dashboard which I am using -  
https://github.com/maxim-uvarov/PQGoogleAnalytics/files/647569/PQGoogleAnalytics2.02.zip

 

After that, I am following steps

  • Open the settings of Power BI, go to the "Privacy" tab, choose the setting "Always ignore the Privacy Level settings".
  • Open the link below in your browser, hit the "Allow" button and copy the given token (I changed client code to my GA account client code) 

https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/analytics.readonly&response_type=code&access_type=offline&redirect_uri=urn:ietf:wg:oauth:2.0:oob&approval_prompt=force&client_id=155297956885-088obc06926s8kolll6kdqkd9u842n56

 

  • Open Power Query by hitting "Edit Queries" button on the "Home" tab on the ribbon of Power BI.
  • Paste the token from the step 1 into "authToken" parameter.
  • Go to "getRefreshToken" query and Copy the token from your preview window.
  • Paste the token from the step 5 into "refreshToken" parameter.

 

After pasting the “refreshToken” I clicked “close and apply” button in the power BI, I am getting following error

 

I tried other options(Windows,A PI, Basic etc.) for authentication but not able to connect.

  • Hi ayush,

    Based on your steps, I could nof figure out what you want to get in your advanced editor:

    1. The token I got from the link means what? I saw you have used it as parameter but I could not figure out how to use.
    2. The 'code' and 'url' you written in the advanced editor seem stitching many parts of code, could you please offer more information about it? And the app_crendentials stands for what

     

    Regards,

    Daniel He

3 Replies

  • v-danhe-msft's avatar
    v-danhe-msft
    Microsoft Employee

    Hi ayush,

    Based on your steps, I could nof figure out what you want to get in your advanced editor:

    1. The token I got from the link means what? I saw you have used it as parameter but I could not figure out how to use.
    2. The 'code' and 'url' you written in the advanced editor seem stitching many parts of code, could you please offer more information about it? And the app_crendentials stands for what

     

    Regards,

    Daniel He

      • v-danhe-msft's avatar
        v-danhe-msft
        Microsoft Employee

        Hi ayush,

        It's pleasant that your problem has been solved, could you please mark a reply as Answered?

         

        Regards,

        Daniel He