Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
short:
I am looking to maintain and use tokens recieved in one query, to be used in all other subsequent queries.
long:
I am a REST api developer, and I have an increase in customers that want to import data into Power Bi. Unfortunately, our access tokens are relatively short lived, and I did not want the end-user (usually not very code-savy) to have to work and renew this token themselves and store this data in a static parameter.
I've tried storing the data in existing parameters, but those values do not change from the default in subsequent queries. I've also tried with local parameters in a query, but these parameters do not exist in future queries. A method that comes closest is this pseudocode:
<Query>
--AuthBody--
apiKey = restapiurl/getapikey?key=secret
accessKey = restapiurl/getaccesskey [HEADER apitoken = apiKey]
--End AuthBody--
Source = resapiurl/getreportdata [HEADER apitoken = apiKey, useraccess=accessKey]
</Query>
The problem with this method is that authorization calls have to be made for every single data query.
I'm just looking for a more efficient method where the apiKey and accessKey values can be set once (and updated upon refresh), then used for other queries.
Thanks.
Sorry, no idea on this.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Check out the July 2025 Power BI update to learn about new features.