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.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
102 | |
48 | |
19 | |
13 | |
11 |