JoeVBAHelp
New Member
- Joined
- Aug 25, 2016
- Messages
- 14
Hi experts
I am having an issue with a cicular reference within Power Query when using refresh tokens
Basically, use refresh token than returns and access token which I feed into get the results.
The problem is when the refresh token is run and updates, I need to use that output next time.
But that means query (reftoken1) needs to be updated by / and feed into the Data query.
I have solved by storing a table in excel but this wont work for Power BI.
Basically what I need:
Refreshtoken1 = feeds into the data
Data = returns new refresh token
Refreshtoken2 = from Data (new token)
If refreshtoken1 <> refreshtoken2 then Refreshtoken2 else refreshtoken1
anyone have any ideas on how to fix this ( I was thinking I need to declare a variable but i don't think this is possible)
I am having an issue with a cicular reference within Power Query when using refresh tokens
Basically, use refresh token than returns and access token which I feed into get the results.
The problem is when the refresh token is run and updates, I need to use that output next time.
But that means query (reftoken1) needs to be updated by / and feed into the Data query.
I have solved by storing a table in excel but this wont work for Power BI.
Basically what I need:
Refreshtoken1 = feeds into the data
Data = returns new refresh token
Refreshtoken2 = from Data (new token)
If refreshtoken1 <> refreshtoken2 then Refreshtoken2 else refreshtoken1
anyone have any ideas on how to fix this ( I was thinking I need to declare a variable but i don't think this is possible)
Power Query:
authKey = "Basic " & Binary.ToText(Text.ToBinary(access_key & ":" & secret_key),0),
url = "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",
// Uses POST method to obtain a bearer token
GetJson = Web.Contents(url,
[
Headers = [#"Authorization"=authKey,
#"Content-Type"="application/x-www-form-urlencoded;charset=UTF-8"],
Content = Text.ToBinary("grant_type=refresh_token&refresh_token="&refreshtoken) //this is the circular reference -refreshtoken comes from the output to this query
]
),
Res = Json.Document(GetJson)
in
Res