I have used OAuth for integrating facebook in my app and I am able to log in successfully but my apps gets stuck on permissions page and it is not moving further. Below is my code:
var auth = new OAuth2Authenticator(
clientId: Constants.AppId,
scope: Constants.ExtendedPermissions,
authorizeUrl: new Uri(Constants.AuthorizeUrl),
redirectUrl: new Uri(Constants.RedirectUrl));
auth.Completed += async (s, eargs) =>
{
if (!eargs.IsAuthenticated)
{
return;
}
else
{
var token = eargs.Account.Properties["access_token"];
UserBean fbBean = new UserBean();
// Now that we're logged in, make a OAuth2 request to get the user's info.
var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me?fields=id,name,picture,email"), null, eargs.Account);
var result = await request.GetResponseAsync();
string resultText = result.GetResponseText();
var obj = JsonValue.Parse(resultText);
Console.WriteLine(token + " -=- " + resultText);
/// handling Name as separate first and last name
string lname = (obj.ContainsKey("name")) ? obj["name"].ToString() : "NotMentioned";
var lastname = lname.Replace("\"", "");
Console.WriteLine("Name: " + lastname);
string email = (obj.ContainsKey("email")) ? obj["email"].ToString() : "Not Mentioned";
var FbEmail = email.Replace("\"", "");
Console.WriteLine("Email: " + FbEmail);
//Regex.Replace(lastname, "[^a-zA-Z0-9_.]+", "", RegexOptions.Compiled);
//Regex.Replace(FbEmail, "[^a-zA-Z0-9_.]+", "", RegexOptions.Compiled);
var names = lastname.Split(' ');
fbBean.last_name = names[names.Length - 1];
Console.WriteLine("Last Name: " + fbBean.last_name);
int i = 0;
string fname = null;
while (i < names.Length - 1)
{
fname = fname + " " + names[i];
i++;
}
// String logic ends
fbBean.first_name = fname.TrimStart();
Console.WriteLine("First Name: " + fbBean.first_name);
fbBean.email = FbEmail;
fbBean.reg_type = "fb";
RestService rest = new RestService(fbBean);
UserBean successBean = await rest.signupUser();
Console.WriteLine("REST Return" + successBean.success);
if (successBean.success != 1)
{
App.FailFlag = true;
}
else
{
//Xamarin.Forms.Application.Current.Properties["IsUserLoggedIn"] = "true";
successBean.reg_type = "fb";
new AppData(successBean);
}
Xamarin.Forms.Application.Current.MainPage = new SignUpConfirm();
}
};
Any idea, why my app is not moving further when I click on "Continue as..." ??????