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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kenkelr
New Member

Storing rest api tokens to be used cross query

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.

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @kenkelr ,

By my research and test, there is no good solution for your scenario.

Hope @ImkeF  could give you some suggestions.

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors