I have a Xamarin.iOS project and I want to authenticate with Azure. The end goal is to not have the user login, and to authenticate behind the scenes. When I instantiate AuththenticationContext I get this Error. "Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory.Platform'". I installed Microsoft.IndentityModel.Clients.ActiveDirectory v3.13.9 from Nuget and the using statement is at the top of the code. The DLL is set to copy local. I don't know why this is not working. I even unintalled the Nuget Package and added the DLL's to the project and referenced them directly and got the same error. Below is the code that I am trying to make work. Again it breaks when AuthenticationContext is instantiated so I cant even test the rest of it. I have used the following two websites for guidance, https://blog.xamarin.com/authenticate-xamarin-mobile-apps-using-azure-active-directory/
I found this "bug" here, but the fix does not work, nor does it make sense to me. Im not sure where to put the code and I get the access error as well. https://forums.xamarin.com/discussion/45425/azure-authentication-microsoft-identitymodel-clients-activedirectory-platform-no-working
var authContext = new AuthenticationContext(aadInstance);
ClientCredential clientCredential = new ClientCredential(clientId, appKey);
// ADAL includes an in memory cache, so this call will only send a message to the server if the cached token is expired.
AuthenticationResult result = authContext.AcquireTokenAsync(AMServiceResourceId, clientCredential).Result;
WebRequest Request =
WebRequest.Create(
new Uri(@<API call to test connection>));
Request.ContentType = "application/json";
Request.Method = "Get";
Request.Proxy = null;
Request.Timeout = 5000;
Request.Headers.Add("Authorization", "Bearer" + result.AccessToken);