Wizcorp / phonegap-facebook-plugin

The official plugin for Facebook in Apache Cordova/PhoneGap
Other
1.91k stars 2.01k forks source link

Session: an attempt was made to request new permissions for a session that has a pending request #294

Open lfglopes opened 11 years ago

lfglopes commented 11 years ago

Greetings,

I'm attempting to request read&write permissions the following way,

    FB.login(function(response) {
        if (response.authResponse) {
            if (true) { //TODO change condition for first login
                FB.login(null, {scope: fbAccess.fbWritePermissions});
            }
            //....
       }
    }, {scope: fbAccess.fbReadPermissions});

But I get back an alert "Something went wrong" with the message that i'm using as title of this issue. Am I doing something wrong or this is actually an issue?

Thanks in advance

Edit: i forgot to mention the app is running on Android 4.0.3, facebook SDK v3 and phonegap 2.5

kerryknight commented 11 years ago

@lfglopes -- Unless I'm missing some outlier functionality you're trying to achieve, it seems to me you're making two calls to FB.login() when you only need to make one. Combine the calls, adding all the read&write permissions you need into the scope list at once. Does that help?

FB.login(function(response) {
     //handle response here
     if (response.authResponse) {
          //do stuff here, no need to make another call for more permissions to FB.login()
     }    
}, {scope:'publish_actions, email, read_stream, etc.'}); //comma-separated list of permissions required here

See docs on FB.login here: FB.login()

All the available permissions are located here: FB permissions

lfglopes commented 11 years ago

Thanks for your reply :)

Facebook Android SDK does not allow requesting read&write permissions at the same time, it looks like implements the methods com.facebook.Session.requestNewPublishPermissions and com.facebook.Session.requestNewReadPermissions.

You can also find this at the plugin's source code:

   if (publishPermissions && readPermissions) {
                pr = new PluginResult(PluginResult.Status.ERROR, "Cannot ask for both read and publish permissions.");
lfglopes commented 11 years ago

I managed this issue using setTimeout after the read permissions request.

Even though, it would be nice to support the two kinds of permissions at the same like I think the JS SDK does and @kerryknight suggested. On the native side, this would call requestNewPublishPermissions right after requestNewReadPermissions.

liubko commented 9 years ago

I think I run into the same issue. Session: an attempt was made to request new permissions for a session that has a pending request

facebookConnectPlugin.login(
  ["public_profile"],
  data => {   // Success callback

  },
  err => {     // Fail callback
    console.log("Error:", err); 
    // Session: an attempt was made to request new permissions for a session that has a pending request
  }
);

I have this problem only on Android. I use: com.phonegap.plugins.facebookconnect 0.11.0 "Facebook Connect" cordova 4.1.2 Android 5.*

@lfglopes @kerryknight any thought on this?

robksawyer commented 8 years ago

:+1:

Any conclusion on this? I'm trying to use the following issues and running into the error as well.

var permissions = ['public_profile','email','user_location','user_about_me','user_birthday','user_website'];

The error:

ERROR: Cannot ask for both read and publish permissions.