Xamarin iOS ClientAssertionCertificate reference error
BradleyDHobbs opened this issue · 2 comments
Which platform has the issue?
Xamarin iOS
What authentication flow has the issue?
Mobile app when acquiring token for client side encryption.
Is this a new or existing app?
This is a new app or experiment
Repro
When I build the project while connected to a physical iOS device, i get the reference error. iOS simulator works fine.
private async Task<string> GetTokenAsync(string authority, string resource, string scope)
{
if (!string.IsNullOrWhiteSpace(Token))
return Token;
var authContext = new AuthenticationContext(authority);
ClientCredential clientCred = new ClientCredential(
"clientid",
"clientsecret");
AuthenticationResult result = await authContext.AcquireTokenAsync(resource, clientCred);
if (result == null)
throw new InvalidOperationException("Failed to obtain the JWT token");
return result.AccessToken;
}
Expected behavior
The build should not throw any errors similar to the iOS simulator behavior.
Actual behavior
Build throws an error when debugging on physical device
Additional context/ Logs / Screenshots
error MT2002: Failed to resolve "Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertionCertificate" reference from "Microsoft.IdentityModel.Clients.ActiveDirectory, Version=4.3.0.0, Culture=neutral,
@BradleyDHobbs : Client Credentials is not available on mobile platforms (for security reasons)
Also, if this is a new project, we recommend you use MSAL.NET.
Yes this is a new project. Trying to do client side encryption for sensitive document images taken from the camera.
So I would use MSAL.NET to acquire a security token to authenticate with Azure Key Vault?