I have a WPF application, and I'm following this tutorial: https://blogs.msdn.microsoft.com/dsnotes/2017/05/10/adal-secure-web-api-with-adfs-3-0-for-desktop-client/ to get WPF to authenticate with ADFS.
I have a button on the main page, and here's the code behind for the button click event handler:
string authority = "https://server1.mycompany.local/adfs";
string resourceURI = "https://localhost/MyWebAPIsample/";
string clientID = "bdf737f9-567a-4998-b5e5-500b9bc2d776";
string clientReturnURI = "https://arbitraryreturnuri/";
var authContext = new AuthenticationContext(authority, false);
var authResult = await authContext.AcquireTokenAsync(resourceURI, clientID, new Uri(clientReturnURI), new PlatformParameters(PromptBehavior.Auto));
At the last line var authResult = await ...
I get this error:
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException: ' The browser based authentication dialog failed to complete. Reason: The request could not be processed by the server due to invalid syntax.'
and authentication_ui_failed
But, on the UI, I clearly see the authentication window popup and I can type in my AD credentials to log in. I've tried fixes from other posts, but I can't seem to figure out what's wrong. Is there anything blatantly wrong with my code or anything I should double check to figure out what's happening? I'm still new to AD, ADFS and ADAL libraries. Thank you!
Notes: I'm using Visual Studio 2017 with Windows Server 2016. I have a NodeJS backend but that's not relevant for this discussion I don't think.