Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ayush
Frequent Visitor

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&r...

 

  • 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

 PBI.PNG

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

1 ACCEPTED SOLUTION
v-danhe-msft
Microsoft Employee
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.1.PNG
  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 what2.PNG

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-danhe-msft
Microsoft Employee
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.1.PNG
  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 what2.PNG

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-danhe-msft Thanks for the response. Got the results.

 

Regards,

Ayush

Hi @ayush,

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

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors