我关注This Page以及来自Xamarin.Auth github repo的一些示例,因此设置了facebook登录名。我创建了以下登录功能:
//table[@class="magic"]//tr[@class="head" and ./th[contains(., "United States")]]/following-sibling::tr[@class="section-break"][1]
但是我在最后一行得到以下异常:
public void Authenticate()
{
string clientId = Config.FacebookAppID;
string redirectUri = redirectUri = "MyApp:/authorize";
var authenticator = new OAuth2Authenticator(
clientId: clientId,
scope: "public_profile,email",
authorizeUrl: new Uri("https://www.facebook.com/v2.9/dialog/oauth"),
redirectUrl: new Uri(redirectUri),
getUsernameAsync: null,
isUsingNativeUI: true);
authenticator.AllowCancel = true;
authenticator.Completed += OnAuthCompleted;
authenticator.Error += OnAuthError;
Authenticator = authenticator;
var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(Authenticator);
}
任何想法我可能做错了什么?
答案 0 :(得分:0)
我知道这已经有一年多了,但是,在经过指导的链接式培训之后,我遇到了同样的问题。
答案是在AuthenticationConfiguration
类的FinishedLaunching
方法中初始化AppDelegate
。
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
// Override point for customization after application launch.
// If not required for your application you can safely delete this method
// Add the Init() method here
global::Xamarin.Auth.Presenters.XamarinIOS.AuthenticationConfiguration.Init();
return true;
}