I've been having a problem when trying to access a Facebook profile in C#, with the Facebook SDK.
I've been using the OAuth2Authenticator from Xamarin.Auth, to generate an access token and all seems fine. However, when I try to get the actual profile information, the only thing I'm getting is:
- Id
- Full name
I can't seem to get the public_profile in any way. I've been trying to solve the problem for hours but I just can't seem to fix it. I've been messing around with my Facebook app settings, code, but nothing seems to work.
My code is as follows:
private void BtnFacebookLogin_Clicked(object sender, EventArgs e)
{
IDictionary<string, object> result = new Dictionary<string, object>();
var auth = new OAuth2Authenticator(FacebookAppId, "", new Uri("https://m.facebook.com/dialog/oauth/"), new Uri("http://www.facebook.com/connect/login_success.html"));
auth.AllowCancel = true;
var ctx = Forms.Context as MainActivity;
auth.Completed += (s, eventArgs) =>
{
if (eventArgs.IsAuthenticated)
{
FacebookClient fb = new FacebookClient(eventArgs.Account.Properties["access_token"]);
fb.AppSecret = auth.ClientSecret;
fb.AppId = "XXXXXXXXXXXXXX";
var parameters = new Dictionary<string, object>();
result = (IDictionary<string, object>) fb.Get("me");
Content = GenerateProfilePage(result);
}
};
ctx.StartActivity(auth.GetUI(ctx));
}
I really hope you guys can help me.