Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi Team,
I am trying to build a secured role based custom connector which provides list of REST apis with parameters.
Before even my connector lists apis, I want to build a login prompt in power bi which asks for url username and password. On hitting this, generates a toke. I want to use this token as a header for my next screen which shows the list of APIS.
How to build this loging promt using power query? Please help!
Thanks in advance!
Solved! Go to Solution.
Cracked the solution,
Here's my custom solution:
(CRScheme as text, CRHostName as text, CRPort as text, CRusername as text, CRpassword as text, optional swaggerUrl as text) =>
let
// delcare types
// step1: Login to get the auth token
body = Text.ToBinary("{""username"":"""& CRusername & """,""password"":"""& CRpassword & """}"),
options = [
Headers = [#"Content-type"="application/json"],
Content = body
],
// Build the authentication URL
AuthenticationUrl = CRScheme & "://" & CRHostName & ":" & CRPort & AuthenticationBaseUrl,
tokenResonse = Json.Document(Web.Contents(AuthenticationUrl, options)),
// step2: Set the access token as part of API request header with additional options
DefaultRequestHeader = [
#"X-Authorization" = tokenResonse[token] // assign the token value obtained from step1
],Thanks!
Cracked the solution,
Here's my custom solution:
(CRScheme as text, CRHostName as text, CRPort as text, CRusername as text, CRpassword as text, optional swaggerUrl as text) =>
let
// delcare types
// step1: Login to get the auth token
body = Text.ToBinary("{""username"":"""& CRusername & """,""password"":"""& CRpassword & """}"),
options = [
Headers = [#"Content-type"="application/json"],
Content = body
],
// Build the authentication URL
AuthenticationUrl = CRScheme & "://" & CRHostName & ":" & CRPort & AuthenticationBaseUrl,
tokenResonse = Json.Document(Web.Contents(AuthenticationUrl, options)),
// step2: Set the access token as part of API request header with additional options
DefaultRequestHeader = [
#"X-Authorization" = tokenResonse[token] // assign the token value obtained from step1
],Thanks!
Great @Anonymous
& thanks for sharing !!
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
Hi Nagpraveen,
The login windows is usually show when you connect to source, but it seems that you want to use dynamic credential to get data in API by M code. I am not professional in this part(token part), so I suggest that you could ask @ImkeF for more sugestions.
Best Regards,
Zoe Zhi
Sorry, but I'm not aware of such an option.
You might want to post an issue in the custom connecotr GitHub repository instead: https://github.com/microsoft/DataConnectors
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
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 8 | |
| 7 |