Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
I'm developing an Azure worker role application which pushes data to PowerBI.com service.
I referred a C# sample client application via Git Hub. But it authenticates using GUI (redirect uri) during the below step.
>> token = authContext.AcquireToken(resourceUri, clientID, new Uri(redirectUri)).AccessToken.ToString();
I need a sample code without GUI (redirect uri) authentication which means silent mode authentication.
Thanks,
-Seiji
Solved! Go to Solution.
You can use the user name and password flow that AAD supports. This 3rd party client library has an example: https://github.com/Vtek/PowerBI.Api.Client
So in my case, when I log into Power BI using our company SSO, I use the my internal company AD network username and password.
Are you saying these should work ok?
Oh and I take it your code is designed to work with a Web app? I'm trying to use and SSIS script task to push rows up to a Dataset\table.
The big catch is that you have to give permissions the first time. In my case, the account that "owns" the dataset is my personal account. I had to set up my app to use traditional authentication wiht a redirect, and go through the typical permisson acceptance to let PowerBI know that I approve the permissions I identified when registering the app. Once i did that, I was able to use my username and password and make an automatic call every 30 minutes with no user intervention. If this isn't clear, please let me know and we can have a quick call to clarify
I keep getting a 400 error "Bad Request". I'm not entirely sure I'm using the correct values for the TenantID, username/password etc.
I ripped the TenantID out of the page source of Power BI HTML page after logging in.
I've tried a few combinations but allways seem to get the 400 error.
Very frustrating.
Hi,
I get the same error "Bad Request" . I think my TenantID, user and password are correct but always get the same error, I try different combinations "/oauth2/v2.0/token" "/oauth2/token/" but not work.
Currently is valid this way of access or there have to access by power bi embedded?
I can handle that for now.
I take it you used a web-app rather than the native-app given there is a client-secret in your code.
Hi,
I am bit confused as to where I can call this code for test. I am new to C# and it may be the reason for confusion. However I went thru some sample codes in sample application embed-a-tile-into-an-app (Github -dvana/PowerBI-CSharp) etc.. Any chance you could explain some dtails on how to use this code etc..
Regards,
Vish.
You can use the user name and password flow that AAD supports. This 3rd party client library has an example: https://github.com/Vtek/PowerBI.Api.Client
I did this by using the refresh token provided by the GUI authentication process and only using the AcquireTokenByRefreshToken method in my worker with the this token. I now just have to refresh the RefreshToken after a few days and update the configuration of my cloud worker (stored in redis -> worker checks for updated token). I do not re-use the Refresh Token in the configuration for every authentication request though but the new ones provided by AcquireTokenByRefreshToken.
@aevers what you say makes sense, but how do you refresh the token after a few days? Have you automated this?
My app doesn't use Active Directory so I will want a single account setup and to silently authenticate to display the report to a certain set of users.
I was thinking that the Active Directory REST api might be another option, but I've not used it before and just reading into it.
Thanks for your suggestion.
I will try it.
Did the suggestion provided by him worked for you. Because i feel the suggestion provided is not relavant to the one you asked. He mentioned as "using the refresh token provided by the GUI authentication process" but as per my understanding its not the question you asked. I guess asked not to redirect to the loginpage, instead it should authenticate silent through code and get the "code" parameter in turn.
Thanks for your message.
Actually his answer doesn't completely adapt to my requirement in the point of GUI less.
But that's an useful workaroound.
Azure Stream Analytics (ASA) also requires Web GUI authentication on management portal when we select Power BI output.
I've been thinking that his workaround is an only solution because ASA behaves so.
Do you know how to implement silent authentication ?
Regards,
-seiji
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.