You should first go to https://developers.facebook.com/apps and register as a facebook developer.
In the app if you want to read the user's details from facebook to allow simplier registration, you can then read the data using:
if (user != null)
{
// Successful. Now you can use the data.
}
In the app if you want to allow logging in with facebook, then a secure approach is the following:
Button code:
if (accessToken.HsaValue())
{
// Successful. Now use the API to generate a login token.
var sessionToken = await HttpPost<string>("v1/login/facebook/" + accessToken);
Device.IO.File("SessionToken.txt").WriteAllText(sessionToken);
}
API Code:
public IHttpActionResult LoginWithFacebook(string accessToken)
{
var json = ("https://" + "graph.facebook.com/me?fields=email&access_token=" + accessToken).AsUri().Download();
var email = JsonConvert.DeserializeObject<JObject>(json)?.Property("email")?.Value?.ToString();
if (email.IsEmpty()) return BadRequest("Invalid email.");
var member = Database.Find<Member>(m => m.Email == email);
if (member == null) return BadRequest($"The email '{email}' is not registered in our system. Please register.");
var result = JwtAuthentication.CreateTicket(member);
return Ok(result);
}