New Enterprise DNA Initiatives

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!

Hi @judy_fmf, we aim to consistently improve the topics being posted on the forum to help you in getting a strong solution faster. While waiting for a response, here are some tips so you can get the most out of the forum and other Enterprise DNA resources.

  • Use the forum search to discover if your query has been asked before by another member.
  • When posting a topic with formula make sure that it is correctly formatted to preformatted text </>.
    image
  • Use the proper category that best describes your topic
  • Provide as much context to a question as possible.
  • Include the masked demo pbix file, images of the entire scenario you are dealing with, screenshot of the data model, details of how you want to visualize a result, and any other supporting links and details.

I also suggest that you check the forum guideline How To Use The Enterprise DNA Support Forum. Not adhering to it may sometimes cause delay in getting an answer.

Please also check the How To Mask Sensitive Data thread for some tips on how to mask your pbix file.