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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
angeloola
Helper I
Helper I

Bearer Token as Parameter/Variable in Power Query M

Hello (not sure if my last post sent through).

 

I am calling an API service in Power BI and need to authenticate using Authorization header and Bearer Token. I need to fetch a new token weekly.

 

Right now, the token value is hard-coded into my Advanced Editor code for each endpoint (see sample code below), but I would like to call a parameter for this instead. I've tried using standard parameter syntax, but am having trouble.

 

Here is the current M code that is calling the API: 

let
Source = Json.Document(Web.Contents("Request URL", [Headers=[Authorization="Bearer eyJhbGciOiJub25lIiwi...."]])),
Data = Source[Data],
#"Converted to Table" = Record.ToTable(Data),
Value = #"Converted to Table"{0}[Value],
#"Converted to Table1" = Table.FromList(Value, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table1", "Column1", {"id", "name"}, {"id", "name"})
in
#"Expanded Column1"

 

I have set up a parameter for the Bearer Token and want to feed that into the code above (see red bold text):

angeloola_0-1597166171785.png

 

Can someone help me out with the syntax? How can I modify the M to accept the parameter value for my token?

 

Thank you!!

 

4 REPLIES 4
amitchandak
Super User
Super User

Thanks for the reply, but I can get the token no problem - what I really need is just the syntax to load the parameter value into the Authorization header value in the Advanced Editor. Can you help with that?

@angeloola  did you ever get this to work? I have the same problem. I have the powerquery returning a token but I want to store that in a variable that can be used by other tables.

Hello, I'm very interested about this subject.

I don't use embed power bi, in query, I am using 2 different acess token about the saas application where the data are stored.

The answer of your question : look this video, I'm sure you'll find the solution of your problem.

https://www.youtube.com/watch?v=2RZkc_qrV1g

And be careful about this: https://docs.microsoft.com/en-us/power-bi/admin/desktop-privacy-levels

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors