Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

App for Admin Permissions

AhirAhir USMember ✭✭

This Error

This is My code

public class LoginPageRenderer : PageRenderer
{
public LoginPageRenderer()
{
var activity = this.Context as Activity;

        var auth = new OAuth2Authenticator(
            clientId: "4155002647916926235", // your OAuth2 client id
            scope: "", // the scopes for the particular API you're accessing, delimited by "+" symbols
            authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"),
            redirectUrl: new Uri("http://www.facebook.com/connect/login_success.html"));

        auth.Completed += async (sender, eventArgs) => {
            if (eventArgs.IsAuthenticated)
            {
                var accessToken = eventArgs.Account.Properties["access_token"].ToString();
                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.facebook.com/me"), null, eventArgs.Account);
                var response = await request.GetResponseAsync();
                var obj = JObject.Parse(response.GetResponseText());

                var id = obj["id"].ToString().Replace("\"", "");
                var name = obj["name"].ToString().Replace("\"", "");

                await App.NavigateToProfile(string.Format(id, name));
            }
            else
            {
               await App.NavigateToProfile("Not login");
            }
        };

        activity.StartActivity(auth.GetUI(activity));
    }
}
Sign In or Register to comment.