Rerequest a facebook permission with Xamarin.Auth

I´m trying to re-asking for declined permissions in Facebook.

According to facebook developers, once someone has declined a permission, the Login Dialog will not re-ask them for it unless you explicitly tell the dialog you're re-asking for a declined permission.

You do this by adding the auth_type=rerequest parameter to your Login.

I made this, but dosen´t work

var auth = new OAuth2Authenticator(
            clientId: "my app id", // your OAuth2 client id
            scope: "email", // 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"));

        progressDialog.Show();
        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);

                IDictionary<string, string> hashRequest = new Dictionary<string, string>();
                hashRequest.Add("auth_type", "rerequest");

                var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me?fields=education,email,location,name"),hashRequest, eventArgs.Account);
                var response = await request.GetResponseAsync();
                var obj = JObject.Parse(response.GetResponseText()); ...

Upvotes: 0

Views: 298

Answers (1)

I Resolved the problem appending some properties to the html request.

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

Upvotes: 1

Related Questions