问题
Using plain Xamarin.iOS how do I sign into Azure AD B2C?
I know there is an example for Xamarin.Forms but I am unable to adapt it for Xamarin.iOS
回答1:
Use the Microsoft Authentication Library (MSAL) in your mobile application to initiate an authentication workflow with your Azure Active Directory B2C tenant.
On the iOS platform, the AppDelegate class must be modified to initialize a PlatformParameters instance, as demonstrated in the following code example:
using Microsoft.Identity.Client;
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
var result = base.FinishedLaunching(app, options);
App.AuthenticationClient.PlatformParameters = new PlatformParameters(UIApplication.SharedApplication.KeyWindow.RootViewController);
return result;
}
}
The PlatformParameters instance is used by MSAL to recognize the platform on which it's running in order to select the platform-specific authentication user experience and token storage mechanism.
For more informatio see documentation.
来源:https://stackoverflow.com/questions/45719583/how-to-sign-into-azure-ad-b2c-using-only-xamarin-ios