Circular reference (API refreshtoken)

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)

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
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,223,634
Messages
6,173,475
Members
452,516
Latest member
archcalx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top