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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Rest API Google Analytics connection failed in Dataflows

Hi!

I am connecting to Google Analytics via rest API. I have followed the steps and code shared in this GitHub  @MAXIM_UVAROV . 

 

Whereas in PowerBI Desktop works fine, when i try to get refresh token in Dataflows it always  fails. I guess something is failing with the function Web.Contents ()  but I am not sure. Any help would be really appreciated.

 

This is my code:

 

let
    app_credentials = "client_id=xxxxxxxxxxxxx.apps.googleusercontent.com&client_secret=xxxxxxxxxxx",
   code = "code=" & authToken,
   url = code & "&" & app_credentials & "&redirect_uri=urn:ietf:wg:oauth:2.0:oob&grant_type=authorization_code",
   GetJson = Web.Contents("https://accounts.google.com",
              [
                     RelativePath = "/o/oauth2/token",
                     Headers = [#"Content-Type"="application/x-www-form-urlencoded"],
                     Content = Text.ToBinary(url),
                     ManualStatusHandling = {400}
              ]
   ),
   Json2 = Json.Document(GetJson),
   refreshTokenOutput = try Json2[refresh_token] otherwise Text.Combine({Json2[error]?, Json2[error_description]?, "Bad     authToken"}, " / ")

 

in
refreshTokenOutput

 

Thanks in advanced!

 

2 REPLIES 2
MAXIM_UVAROV
Frequent Visitor

Hey @Anonymous , sorry, haven't tried dataflows with google analytics yet. I'm not sure that I will be able to do that soon. But if I will - I'll let you know

Anonymous
Not applicable

Thank for your response @MAXIM_UVAROV 

 

I also wanted to thank you for sharing your custom connector script. It is awesome 🙂

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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