Estou tentando criar um login com fb no meu aplicativo em Xamarin. O problema é que o Fb não retorna o e mail e as permissões estão todas habilitadas no painel do Fb, o identify e id retornam. Ja tentei varias urls e nada. Estou tentando seguir esse exemplo
Testei a URL no browser e tbm não retorna o e mail.
Como resolver isso ?
Estou tentando assim.
utilizing System;
utilizing Xamarin.Types;
utilizing Xamarin.Types.Platform.Android;
utilizing Android.App;
utilizing Xamarin.Auth;
utilizing Newtonsoft.Json.Linq;
utilizing MyApp.View;
[assembly: ExportRenderer(typeof(LoginFacebookView), typeof(MyApp.Droid.FBLoginPageRenderer))]
namespace MyApp.Droid
{
public class FBLoginPageRenderer : PageRenderer
{
public FBLoginPageRenderer()
{
var exercise = this.Context as Exercise;
var auth = new OAuth2Authenticator(
clientId: "2xxxxxxxxxxxxxxxx3",
scope: "",
authorizeUrl: new Uri("https://m.fb.com/dialog/oauth/"),
redirectUrl: new Uri("http://www.fb.com/join/login_success.html"));
auth.Accomplished += async (sender, eventArgs) => {
if (eventArgs.IsAuthenticated)
{
var accessToken = eventArgs.Account.Properties["access_token"].ToString();
//Console.WriteLine(accessToken);
var expiresIn = Convert.ToDouble(eventArgs.Account.Properties["expires_in"]);
var expiryDate = DateTime.Now + TimeSpan.FromSeconds(expiresIn);
//var request = new OAuth2Request("GET", new Uri("https://graph.fb.com/me/permissions?access_token=" + accessToken + "&debug=all"), null, eventArgs.Account);
//var request = new OAuth2Request("GET", new Uri("https://graph.fb.com/me?fields=e mail&access_token=" + accessToken), null, eventArgs.Account);
//var request = new OAuth2Request("GET", new Uri("https://graph.fb.com/me?fields=id,identify,e mail"), null, eventArgs.Account);
var request = new OAuth2Request("GET", new Uri("https://graph.fb.com/v2.9/me?fields=id,identify,e mail"), null, eventArgs.Account);
var response = await request.GetResponseAsync();
Console.WriteLine(response.GetResponseText());
//var obj = JObject.Parse(response.GetResponseText());
//var id = obj["id"].ToString().Exchange(""", "");
//var identify = obj["name"].ToString().Exchange(""", "");
//var e mail = obj["email"].ToString().Exchange(""", "");
// Console.WriteLine("Nome: " + identify + ", e mail: " + e mail);
//await App.NavigateToProfile(string.Format("Olá {0}, seja bem-vindo", identify));
}
else
{
//await App.NavigateToProfile("O usuário Cancelou o login");
}
};
exercise.StartActivity(auth.GetUI(exercise));
}
}
}