Forum Discussion
AcquireTokenAsync fails while retrieving accesstoken
Hi jitensahu ,
The error message indicates that the connection to remote server has been closed by remote server, please cehck the connection to the remote server, besides, also check if the token is true.
Best Regards,
Teige
Hi TeigeGao ,
How do I check the connection to remote server?
I have downloaded migration application(Migration from workspace collection to emnedded) from msdn link and tried to migrate few pbix files. It did work. I could deploy pbix to workspace using migration solution. However, that requires me to manually enter emailid for authentication.
Then I tried to automate it without manually entering the emailid by using AcquireTokenAsync method. It didn't work.
I have seen powerbi videos where the presenter downloads the sample app after deploying the pbix using https://app.powerbi.com/embedsetup . And that works for them just after altering password in config file. However same doesn't work for me.
Do you think there is an issue in firewall and organization is blocking the call somehow? Or do you think there is some other issue? The code I use is very simple to get the token. Below is the code
string userName = "[email protected]";
string password = "xxxxxx";
string clientId = "61107d03-5f13-4a87-b2c5-910a85aec62b";
var credentials = new UserPasswordCredential(userName, password);
var authenticationContext = new AuthenticationContext("https://login.windows.net/common/oauth2/authorize/");
var result = await authenticationContext.AcquireTokenAsync("https://analysis.windows.net/powerbi/api", clientId, credentials);