I have created a function to login using 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));
}
The thing is that after I enter my credentials in the FB login page, an exception is thrown before it reaches the Completed
event.
I've downloaded the Xamarin.Auth project from GitHub trying to debug the program, but it doesn't break at the breakpoint unfortunately.
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]
I'm struggling with this issue for a while now. Please help!