【发布时间】:2018-06-21 14:36:37
【问题描述】:
我有一个使用 azure Active Directory 身份验证的 Xamarin Forms 应用程序。
我正在使用 NuGet 数据包 Microsoft.Azure.Mobile.Client 版本 3.1.0,MobileServiceClient 类的 LoginAsync 函数的签名是
Task<MobileServiceUser> LoginAsync(UIViewController view, MobileServiceAuthenticationProvider provider);
适用于 iOS 和适用于 Android 的类似签名。因此,我在 iOS 上的登录功能是这样的:
var window = UIKit.UIApplication.SharedApplication.KeyWindow;
var current = window.RootViewController;
while(current.PresentedViewController != null) {
current = current.PresentedViewController;
}
var user = await MSC.LoginAsync(current, MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory);
return user;
使用此函数,库会将应用程序发送到 Azure Active Directory 网页以进行登录或注册,并返回一个 MobileServiceUser 实例。
该版本按预期工作。
但是,由于应用程序其他部分的一些问题,我不得不将 NuGet 数据包更新到较新的版本,在本例中为 4.0.2。登录功能将签名更改为
Task<MobileServiceUser> LoginAsync(MobileServiceAuthenticationProvider provider, JObject token);
我不知道如何处理最后一个参数才能获得与以前相同的行为。传递null 会抛出异常,传递新的JObject 类不起作用。
【问题讨论】:
标签: azure xamarin.forms