Hi!
I have this "simple" code:
public static async Task<string> RetrieveTokenAsync() { var authContext = new AuthenticationContext("https://login.windows.net/MYTENANT.com/", true, new FileCache()); try { AuthenticationResult result = null; result = await authContext.AcquireTokenAsync(Resource, ClientId, new Uri(RedirectUri), new PlatformParameters(PromptBehavior.Auto), UserIdentifier.AnyUser, "domain_hint=MYTENTANT.com"); if (result == null) { throw new InvalidOperationException("Failed to obtain the JWT token"); } // store token for reuse Console.WriteLine("AccessToken=" + result.AccessToken); return result.AccessToken; } catch (Exception ex) { throw new InvalidOperationException("Could not retrieve token.", ex); } } static void Main(string[] args) { try { RetrieveTokenAsync().Wait(); } }
When calling await authContext.AcquireTokenAsync in a computer that is not connected to Office 365 and I use an account belonging to an office365 account and I enter the user and password it crashes.
This only happens with that user and password... if I use another user but the same password then there is the same crash. So it seems that the problem is related to the password I use... quite strange. It's a simple password of 8 characters.
I tried compiling it against different versions of the Identity package but it's the same.
Any clue?
Thanks