如何仅使用Xamarin.iOS登录Azure AD B2C? [英] How to sign into Azure AD B2C using only Xamarin.iOS?

查看:65
本文介绍了如何仅使用Xamarin.iOS登录Azure AD B2C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用纯Xamarin.iOS如何登录Azure AD B2C?

Using plain Xamarin.iOS how do I sign into Azure AD B2C?

我知道有一个Xamarin.Forms的示例,但我无法使其适应Xamarin.iOS

I know there is an example for Xamarin.Forms but I am unable to adapt it for Xamarin.iOS

推荐答案

使用 Microsoft移动应用程序中的身份验证库(MSAL),以与Azure Active Directory B2C租户启动身份验证工作流.

Use the Microsoft Authentication Library (MSAL) in your mobile application to initiate an authentication workflow with your Azure Active Directory B2C tenant.

在iOS平台上,必须修改AppDelegate类以初始化PlatformParameters实例,如以下代码示例所示:

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;
    }
}

MSAL使用PlatformParameters实例来识别其运行所在的平台,以便选择特定于平台的身份验证用户体验和令牌存储机制.

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.

有关更多信息,请请参阅文档.

这篇关于如何仅使用Xamarin.iOS登录Azure AD B2C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆