Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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 di...
  • Jayendran's avatar
    Jayendran
    6 years ago

    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.0 

     

    2.  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/";