0

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.

Marcel317
  • 21
  • 4
  • You need to be passing in the scope to your authenticate request. See: https://developers.facebook.com/docs/facebook-login/permissions – Ryan Mar 22 '16 at 18:56
  • I've tried that, but then it's still the same result. – Marcel317 Mar 22 '16 at 18:58
  • You need to ask for the fields you want returned now. (Yes, the duplicate is about accessing the API via JS, but the underlying principle is the same.) – CBroe Mar 22 '16 at 18:58

0 Answers0