Forum Discussion
how to push data trough api
Hello,
I'm following this tutorial:
https://docs.microsoft.com/fr-fr/power-bi/developer/walkthrough-push-data
I choosed a native application type in the first step, what should I use for the different uri in the second step? in the native mode, you have only the clientID
https://docs.microsoft.com/fr-fr/power-bi/developer/walkthrough-push-data-get-token
//RedirectUri you used when you register your app.
//For a client app, a redirect uri gives Azure AD more details on the application that it will authenticate.
// You can use this redirect uri for your client app
string redirectUri = "https://login.live.com/oauth20_desktop.srf";
//Resource Uri for Power BI API
string resourceUri = "https://analysis.windows.net/powerbi/api";
//OAuth2 authority Uri
string authorityUri = "https://login.microsoftonline.net/common/";
Thanks for your answer
Hi Anonymous ,
Ok the document is out-dated. Please follow my instruction as below
1. Update the nuget package manager for the Microsoft.IdentityModel.Clients.ActiveDirectory
Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 4.5.1.02. update your code like below
AuthenticationContext authContext = new AuthenticationContext(authorityUri); //update with your master account email and password var userCreds = new UserPasswordCredential("[email protected]", "myEasyToCrackPassword"); var userAuthnResult = authContext.AcquireTokenAsync(resourceUri, clientID, userCreds).Result; string token=userAuthnResult.AccessToken;You don't need the redirect url at all.
ResourceUri and authorityurl remains same as
string resourceUri = "https://analysis.windows.net/powerbi/api"; //OAuth2 authority Uri string authorityUri = "https://login.microsoftonline.com/common/";
10 Replies
- JayendranSolution Sage
Hi Anonymous ,
The Redirect url become valid only for the Web app type registration. Since you used native you can use the one which provided in the code itself
string redirectUri = "https://login.live.com/oauth20_desktop.srf";- AnonymousNot applicable
Hi Jayendran ,
Thanks for you answer, for the resourceUri, I shloud keep the follownig line?
string resourceUri = "https://analysis.windows.net/powerbi/api";I had the window for loggin/password but when I click on the button to connect, I have the following message
- JayendranSolution Sage
Hi Anonymous ,
Ok the document is out-dated. Please follow my instruction as below
1. Update the nuget package manager for the Microsoft.IdentityModel.Clients.ActiveDirectory
Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 4.5.1.02. update your code like below
AuthenticationContext authContext = new AuthenticationContext(authorityUri); //update with your master account email and password var userCreds = new UserPasswordCredential("[email protected]", "myEasyToCrackPassword"); var userAuthnResult = authContext.AcquireTokenAsync(resourceUri, clientID, userCreds).Result; string token=userAuthnResult.AccessToken;You don't need the redirect url at all.
ResourceUri and authorityurl remains same as
string resourceUri = "https://analysis.windows.net/powerbi/api"; //OAuth2 authority Uri string authorityUri = "https://login.microsoftonline.com/common/";