我创建了一个使用 Facebook 登录的功能。
public void Login ()
{
var ctx = Forms.Context as MainActivity;
var accounts =
new List<Account>(AccountStore.Create (ctx).FindAccountsForService (SERVICE));
if (accounts.Count == 1) {
GetAccount (accounts [0]);
return;
}
var auth = new OAuth2Authenticator (
clientId: FBID,
scope: string.Empty,
authorizeUrl: new Uri (AUTH_URL),
redirectUrl: new Uri (REDIRECT_URL));
auth.Completed += (sender, eventArgs) => {
AccountStore.Create (ctx).Save (eventArgs.Account, "Facebook");
GetAccount (eventArgs.Account);
};
ctx.StartActivity (auth.GetUI (ctx));
}
问题是,在我在 FB 登录页面中输入我的凭据后,会在它到达Completed
事件之前引发异常。
我已经从 GitHub 下载了Xamarin.Auth项目,试图调试该程序,但不幸的是它并没有在断点处中断。
Caused by: JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Auth.OAuth2Authenticator.OnRetrievedAccountProperties (System.Collections.Generic.IDictionary`2) [0x00017] in d:\Downloads\Xamarin.Auth-master\Xamarin.Auth-master\src\Xamarin.Auth\OAuth2Authenticator.cs:373
at Xamarin.Auth.OAuth2Authenticator.OnRedirectPageLoaded (System.Uri,System.Collections.Generic.IDictionary`2,System.Collections.Generic.IDictionary`2) [0x00016] in d:\Downloads\Xamarin.Auth-master\Xamarin.Auth-master\src\Xamarin.Auth\OAuth2Authenticator.cs:282
at Xamarin.Auth.WebRedirectAuthenticator.OnPageEncoun...[intentionally cut off]
我现在在这个问题上挣扎了一段时间。请帮忙!