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!