【发布时间】: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