【问题标题】:Azure AD B2C Xamarin.ios NativeAzure AD B2C Xamarin.ios 本机
【发布时间】:2018-09-22 01:37:13
【问题描述】:

我目前正在将 Azure AD B2C 实施到我的 Xamarin.ios 本机应用程序中。但是,我能找到的唯一示例是 Xamarin.Forms,这意味着我必须尝试将其转换为 Xamarin.ios。给出的例子是Xamarin.Forms Azure AD B2C Example

我遇到的问题是我尝试从 Azure 请求访问令牌。它总是返回 System.NullReferenceException。当我在 Forms 中测试实际示例时,它运行良好,我所做的只是将代码从该项目复制到 Ios 中,同时将需要更改的内容更改为 Xamarin.Ios 而不是 Forms。这是下面返回空异常的代码:

async partial void LoginButton(NSObject sender)
    {
        try
        {
            AuthenticationResult result = await App.AuthenticationClient.AcquireTokenAsync(
                Constants.Scopes,
                string.Empty,
                UIBehavior.SelectAccount,
                string.Empty,
                null,
                Constants.Authority);
                //Constants.SignUpSignInPolicy);
            //await Navigation.PushAsync(new LogoutPage(result));
        }
        catch (MsalException ex)
        {
            if (ex.Message != null && ex.Message.Contains("AADB2C90118"))
            {
                //await OnForgotPassword();
            }
            if (ex.ErrorCode != "authentication_canceled")
            {
                //await DisplayAlert("An error has occurred", "Exception message: " + ex.Message, "Dismiss");
            }
        }
    }

【问题讨论】:

    标签: azure xamarin xamarin.ios azure-active-directory


    【解决方案1】:

    我通过使用这个示例(它是一个更新版本)并将代码从这个示例带到 Xamarein.ios 本机,设法让它工作。 Sample I used for Azure AD B2C

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-09
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-17
      • 1970-01-01
      相关资源
      最近更新 更多