I have been researching this issue for days now, pulling my hair out. Another thread that most accurately describes my issue is here, but the suggested solution did not work for me.
I'm creating a cross-platform mobile app using Xamarin Forms, and I am trying to integrate Facebook Login as my means of user authentication. I'm presenting the login page modally, rendering the page in a platform specific manner in each of the mobile platform projects, and using the Xamarin.Auth API to handle the bulk of the authentication. The following snippit is from the Android implementaiton:
var activity = Context as Activity;
var authenticator = new OAuth2Authenticator(
clientId: AppConstants.FacebookAppId,
scope: "",
authorizeUrl: AppConstants.FacebookAuthorizeUri,
redirectUrl: AppConstants.FacebookRedirectUri);
authenticator.Completed += async (sender, eventArgs) =>
{
// Check for authentication, call Graph API, deserialize JSON, etc...
};
activity.StartActivity(authenticator.GetUI(activity));
This is the boiler-plate code that basically every online example gives, and should present a Facebook Login page. However, after clicking my Login with Facebook button, which should push the rendered page modally, all I get is this:
"Not logged in: You are not logged in. Please login and try again."
I have double and triple checked that the clientId
parameter matches my Facebook App ID on my Facebook Developer Console. I have made sure that the redirect and authorization URIs supplied to the OAuth2Authenticator
object are correct. I have added the redirect URI to my Facebook Developer Console. My development keyhash, found using keytool and openssl is also correct. My package name and class name (package.name.MainActivity) are also correct in the console (the package name in my project was set manually by double-clicking the Android project, going to 'Android Manifest', and putting in my own package name). I have removed and readded the Android project from the Facebook Developer Console several times over.
My question is, are there any other steps specific to the Xamarin platform that I may be missing here? I really don't know what the error seems to be. I'd appreciate any help/input on the matter.
Thanks in advance.