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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
nmusters
Regular Visitor

Writing to a parameter (OAuth tokens)

Hi,

So I'm currently constructing a dashboard that uses multiple OAuth endpoints. For context: I have a table of ID's and for each ID I want to check a number of endpoints what the data for that ID is. Because PowerBI doesn't support OAuth I get an refreshtoken using Postman which I feed to PowerBI and use it to get an accesstoken. My problem is the API I use has a accesstoken expiration of 10 minutes and also a limit of the amount of API calls per second causing my accesstoken to expire before the entire table is loaded.

 

Making things difficult is that each time I get an accesstoken, I also get back a new refreshtoken. The solution I came up with would be to store the new refreshtoken to a parameter so I can later use it to get a new accesstoken. However is it possible to do such a thing? Am I approaching this from a completely wrong angle? Or should I rewrite the entire thing to sql or python?

 

Thanks in advance for any help!

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
Employee


@nmusters wrote:

Hi,

So I'm currently constructing a dashboard that uses multiple OAuth endpoints. For context: I have a table of ID's and for each ID I want to check a number of endpoints what the data for that ID is. Because PowerBI doesn't support OAuth I get an refreshtoken using Postman which I feed to PowerBI and use it to get an accesstoken. My problem is the API I use has a accesstoken expiration of 10 minutes and also a limit of the amount of API calls per second causing my accesstoken to expire before the entire table is loaded.

 

Making things difficult is that each time I get an accesstoken, I also get back a new refreshtoken. The solution I came up with would be to store the new refreshtoken to a parameter so I can later use it to get a new accesstoken. However is it possible to do such a thing? Am I approaching this from a completely wrong angle? Or should I rewrite the entire thing to sql or python?

 

Thanks in advance for any help!


@nmusters

In my case, the lifetime of refreshtoken is 14 days by default and the new refreshtoken doesn't make the old expired. For Oath2 authentication, I only worked with Azure AD and the max lifetime of refreshtoken can be as long as 90 days. It is acceptable for me to manually update the pbix every 3 months.

 

For your case, or say for any case, in my opinion, it is not a good practice to handle duplicated authetication/REST API scenario in Power Query, I'd suggest you rewrite the entire thing in python, save the data to some file or database. Then connect to the file/db from Power BI.

 

View solution in original post

1 REPLY 1
Eric_Zhang
Employee
Employee


@nmusters wrote:

Hi,

So I'm currently constructing a dashboard that uses multiple OAuth endpoints. For context: I have a table of ID's and for each ID I want to check a number of endpoints what the data for that ID is. Because PowerBI doesn't support OAuth I get an refreshtoken using Postman which I feed to PowerBI and use it to get an accesstoken. My problem is the API I use has a accesstoken expiration of 10 minutes and also a limit of the amount of API calls per second causing my accesstoken to expire before the entire table is loaded.

 

Making things difficult is that each time I get an accesstoken, I also get back a new refreshtoken. The solution I came up with would be to store the new refreshtoken to a parameter so I can later use it to get a new accesstoken. However is it possible to do such a thing? Am I approaching this from a completely wrong angle? Or should I rewrite the entire thing to sql or python?

 

Thanks in advance for any help!


@nmusters

In my case, the lifetime of refreshtoken is 14 days by default and the new refreshtoken doesn't make the old expired. For Oath2 authentication, I only worked with Azure AD and the max lifetime of refreshtoken can be as long as 90 days. It is acceptable for me to manually update the pbix every 3 months.

 

For your case, or say for any case, in my opinion, it is not a good practice to handle duplicated authetication/REST API scenario in Power Query, I'd suggest you rewrite the entire thing in python, save the data to some file or database. Then connect to the file/db from Power BI.

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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