Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |