0
votes

I am developing a Xamarin.Forms PCL mobile application and need access to an internal API that requires authentication via Azure. My coworker gave me a code snippet that works in a console application, and I am attempting to adapt it for my mobile application.

I am able to successfully add the ADAL package to the PCL. However, authentication requires that I pass along a set of PlatformParameters for each platform-specific version. When I attempt to add the ADAL package to the Xamarin.Android project, I get the following errors in my Resource.Designer.cs file:

ERROR: 'Resource.Id' does not contain a definition for 'agentWebView'
ERROR: 'Resource.Layout' does not contain a definition for 'WebAuthenticationBroker'

The relevant (auto-generated) lines of code in Resource.Designer.cs are:

global::Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.Resource.Id.agentWebView = global::MissionControlAuth.Droid.Resource.Id.agentWebView;      
global::Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.Resource.Layout.WebAuthenticationBroker = global::MissionControlAuth.Droid.Resource.Layout.WebAuthenticationBroker;

The names of these missing resources suggest that I need to point the ADAL package to a webview that can be used to display a login page to the user. Unfortunately, I haven't been able to find any mention of this on StackOverflow or on the Xamarin forums. How can I correctly set up the ADAL package for my Xamarin.Forms PCL?

Platform / Library Versions

  • .NET Framework 4.5
  • Xamarin.Forms v2.0.0.6482 targeting Xamarin.Android and UWP
  • Visual Studio 2015
  • Microsoft.IdentityModel.Clients.ActiveDirectory v3.5.207081303-alpha (relevant answer)
    • Alternatively, Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory v4.0.209160138-alpha (relevant answer)

Steps to Reproduce

  1. Create a new Xamarin.Forms PCL project.
  2. Choose one of the ADAL package versions above and add it to the PCL.
  3. Add the same package version to the Xamarin.Android project. The library will install successfully, but there will be missing resource errors in the "Error List" tab in Visual Studio.
1

1 Answers

0
votes

Experimental library is not supported. Please switch to MSAL available at https://www.nuget.org/packages/Microsoft.Identity.Client