Forum Discussion
AcquireTokenAsync fails while retrieving accesstoken
i am migrating to power bi embedded as App owns data. I have used the microsoft documentation for migration using powerbi playground. After migration, I have downloaded the sample application. When I run it, it gives me below exception. Any idea what's going on?
Ooops, something broke: System.AggregateException: One or more errors occurred.
---> System.Net.Http.HttpRequestException: An error occurred while sending the r
equest. ---> System.Net.WebException: The underlying connection was closed: An u
nexpected error occurred on a send. ---> System.IO.IOException: Unable to read d
ata from the transport connection: An existing connection was forcibly closed by
the remote host. ---> System.Net.Sockets.SocketException: An existing connectio
n was forcibly closed by the remote host
at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
2 Replies
- jitensahuNew Member
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);