The latest version of AuthenticationContext no longer has an AcquireToken method, instead it has AcquireTokenAsync. This article's code sample should be updated to reflect that. Thanks!
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@karmamule Thank you for your feedback! We will investigate and review if we need to change/add the information suggested.
I can confirm it is out of date.
@karmamule and @bpiet2000
This is currently being discussed with the parties involved. Some of whom are still on vacation, so once they return we should have an update.
Thank you.
We apologize for the delay. We are still looking into this issue. Thank you.
Here is a work around that I found and at least work for my case:
string token = authContext.AcquireTokenAsync(resourceUri, clientID, new Uri(redirectUri), new PlatformParameters(PromptBehavior.Auto)).Result.AccessToken;
Instead of AcquireToken I used AcquireTokenAsync, the only inconvenience is that it requires an extra parameter: "IPlatformParameters:
An object of type PlatformParameters which may pass additional parameters used for authorization."
I also had to do a .Result over the returned Task of AcquireTokenAsync before I could call .AccessToken
Hope this solution work for someone else too.
thanks @bvaldeiglesias that worked for me
@bvaldeiglesias Thank you for adding the workaround.
We will now proceed to close this thread. If there are further questions regarding this matter, please tag me in your reply. We will gladly continue the discussion and we will reopen the issue.
Kind of perplexed as to why the article has not been updated. An error has been identified and accepted. Then a solution has been found and explained and accepted. Yet the article remains the same. Why is it not being corrected?
instead of "UserCredential" use "UserPasswordCredential" which works for me
TokenCache TC = new TokenCache();
AuthenticationContext AC = new AuthenticationContext(authority, TC);
UserPasswordCredential UPC = new UserPasswordCredential(asptb_pbiusername.Text, asptb_password.Text);
AuthenticationResult AR = AC.AcquireTokenAsync(Settings.Default.PowerBiAPIResource, Settings.Default.PBiNativeAppID, UPC).Result;
Note : authority = https://login.microsoftonline.com/{TenantGUID}
Most helpful comment
Kind of perplexed as to why the article has not been updated. An error has been identified and accepted. Then a solution has been found and explained and accepted. Yet the article remains the same. Why is it not being corrected?