How to sign into Azure AD B2C using only Xamarin.iOS?

耗尽温柔 提交于 2019-12-12 04:05:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!