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

Authenticating an R or Python script

I was excited to see that Power BI now supports Python scripts, so I put together a quick script to get data from the Zendesk API.

 

With basic auth (username and password) hard-coded, this works in Power BI and pulls the data in. I really need this to work like any other Power BI data source though, and use the Power BI auth credentials/prompts.

 

Is this possible, and if so, how?

 

 

Note that I made a version of this script in both Python and R for testing purposes (I was hoping there'd be more docs for using R script with Power BI, as it has been around for longer). If it's not possible yet in Python but is doable in R, that's also an option.

1 ACCEPTED SOLUTION

Accepted Solutions
samwoolerton Frequent Visitor
Frequent Visitor

Re: Authenticating an R or Python script

Yeah I'm more comfortable with the few people I will work on the report with having access to my credentials than those who I'll share the report with.

 

Thanks for the help all, looks like hard-coding the username and password is the best option for me here

5 REPLIES 5
Highlighted
zoloturu
Advisor

Re: Authenticating an R or Python script

Hi @samwoolerton,

 

The only approach would be:

1) Create Username and Password parameters. See example - https://www.youtube.com/watch?v=iiNDq2VrZPY

2) Use them in M (PowerQuery) script at the beginning

3) Then Populate them to R/Python script.

 

And then you will be able to open parameters window at any time. 

 

Regards,
Ruslan
-------------------------------------------------------------------
Did I answer your question? Mark my post as a solution!

 

samwoolerton Frequent Visitor
Frequent Visitor

Re: Authenticating an R or Python script

Hey Ruslan,

Thanks for the update here - Guyinacube videos are great!
 
Downside of this approach is that any user of the Power BI report can still see those parameters (they're not hidden away like credentials are for other data sources).
 
Any way to get around this?
 
Thanks,
Sam

Moderator v-yuezhe-msft
Moderator

Re: Authenticating an R or Python script

@samwoolerton,

You can directly define parameters(user name and password) in Advanced Editor of your query in Power BI Desktop following the guide in this similar thread, and then create a Power BI report template(.PBIT) .

This way, when each user open the PBIT in Power BI Desktop, they will be prompted to enter username and password.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
zoloturu
Advisor

Re: Authenticating an R or Python script

@samwoolerton@v-yuezhe-msft,

 

On the one hand, approach sounds as an alternative but on the other hand, once you publish a report with such parameters to Power BI Service then your parameters will be opened to everyone who has access to a workspace. 

 

Regards,
Ruslan

samwoolerton Frequent Visitor
Frequent Visitor

Re: Authenticating an R or Python script

Yeah I'm more comfortable with the few people I will work on the report with having access to my credentials than those who I'll share the report with.

 

Thanks for the help all, looks like hard-coding the username and password is the best option for me here