cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Nagpraveen Frequent Visitor
Frequent Visitor

Build Login form using Power query

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Nagpraveen Frequent Visitor
Frequent Visitor

Re: Build Login form using Power query

@ImkeF @dax 

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!

View solution in original post

4 REPLIES 4
Community Support Team
Community Support Team

Re: Build Login form using Power query

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

Super User III
Super User III

Re: Build Login form using Power query

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 

 

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark my post as a solution. Thanks!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




Nagpraveen Frequent Visitor
Frequent Visitor

Re: Build Login form using Power query

@ImkeF @dax 

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!

View solution in original post

Super User III
Super User III

Re: Build Login form using Power query

Great @Nagpraveen   

& thanks for sharing !!

 

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark my post as a solution. Thanks!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Top Solution Authors
Top Kudoed Authors