Please can someone clarify why we have to login twice for email and friends permission

seems to be a problem there too… for me at least

I don’t call login a second time. There is a ‘Connect’ button on my app that calls login. I press it the first time (step 3 in my earlier post), and then because it fails and gets a sdk 5 error, press it a second time (step 7) and it brings me to Facebook permission page but only showing public_profile permission.

The problem is when I delete the permissions through the Facebook app, and launch my game, it logs in successfully. However when I try a request after the login, the request seems to log out the user and return an error for the request.

This wouldn’t be an issue if every other login didn’t alternate between showing 3 permissions to 1 permission. Do you know why it does this?

Lets get a bug filed on it then.  Produce a reproducible test case for engineering please.  Make sure to include your config.lua and build.settings and put it all in a .zip file please.

Rob

Hi Evan / Rob

Sorry for delay in properly responding - I have been away from my pc most of the week so have only just started to do some tests.

I can confirm that I am also getting the weird switching between public profile only and the permissions I want i.e. email and friends.  

I have also managed to replicate this with a very very minimal amount of code which I have posted below…  I have a button that calls fbLogin().  This is the process to replicate

  1. Ensure you have deleted the app from facebook

  2. Open my app and click on my login button

  3. Switches to facebook and shows the correct permission (public, email and friends)

  4. Click ‘Cancel’ and return to my app - event phase is loginFailed which is fine since I cancelled

  5. Click on my login button again 

6) Switches to facebook again but now just shows public permissions

  1. Click ‘Cancel’ - repeat step 2

Evan (and rob if you have time) - can you confirm that you can replicate this behavior consistently using the bare minimum code below? 

local function callFacebook2(event) print( "Facebook Listener events:" ) print( "event.name", event.name ) -- "fbconnect" print( "event.type:", event.type ) -- type is either "session" or "request" or "dialog" print( "isError: " .. tostring( event.isError ) ) print( "didComplete: " .. tostring( event.didComplete) ) print( "eventphase:", event.phase) end function fbLogin(event) -- login to facebook and then get user data facebook.login( appId, callFacebook2, {"email, user\_friends"} ) end

David, can you go ahead and file a bug report with your test case.  Make sure to include the build.settings and config.lua and any assets needed and bundle in a .zip file.

Thanks

Rob

Sure thing Rob - I’ve just submitted that for you guys… Hopefully it will be something easy to fix :slight_smile:

Case 34943

Cheers

Dave

It seems like Dave beat me to filing the bug, but it seems like I’m the only one experiencing the ‘Facebook SDK error 5’ error so I might file another bug as well. I’ll see if I can strip my code and replicate it. I’ll keep you guys updated on this.

Bug was filed: Case 34982

Hi Rob,

Do you know if that bug has been looked at?  Is there a way we are able to check the progress?

Thanks

FYI, these are the pages I have read through that lead me to think there maybe a bug:

https://developers.facebook.com/docs/facebook-login/permissions/v2.0

https://developers.facebook.com/docs/facebook-login/ios/v2.0

I have also notcied in the facebook sample app that ALL of the requests do a “publish_actions” login before doing anything…   Why is this the case if initally all we want is read only info? e.g. in the sample app the getInfo_onRelease / GET_USER_INFO request.

From facebook docs:

“Apps should separate the request of read and publish permissions. Plan your app around requesting the bare minimum of read permissions at initial login and then any publish permissions when a person actually needs them , for example when they want to create an Open Graph story from within the app. This provides the best user experience and optimizes conversion.”

Its assigned to an engineer and is in the queue to work on but no more updates.

Rob

Do me a favor and try:

facebook.login( appId, callFacebook, {“email, user_friends”}  )

Also try just getting one or the other.  I thought I had read somewhere that email and user_friends was included in the basic privs anyway.

Rob

Hi Rob,

Thanks so much for getting back to me… I appreciate my post is a bit on the long side but I wanted to try and show that I’d done the investigation - so thanks for taking the time to read it all!

I have just tried that but it still only gives me the “public profile” (unless I do an initial login first but then im back to two facebook screens)

As a test, I also tried not passing anything in for the permissions and as I expected it still gave me “public profile” since this is the only default permission facebook applies.

i.e. facebook.login( appId, callFacebook, {}  )

These are a couple of paragraphs from the facebook docs that seem to back this up:

This is from the “overview section” of https://developers.facebook.com/docs/facebook-login/permissions/v2.0

 

Permissions are strings that are passed along with a login request or an API call. Here are two examples of permissions:

email - Access to a person’s primary email address.

user_likes - Access to the list of things a person likes.

For example, if you add the login button to a web app and ask for email and user_likes via thescope parameter, a person would be prompted with this dialog when logging in for the first time:

<image removed>

Your app has requested a person’s email address and the things they like but that request also automatically asks for access to a person’s public profile. The full list of permissions, including defaults, is included in this document."

Note the part that I have bolded…

In doing the login you requested:    

facebook.login( appId, callFacebook, {“email, user_friends”}  ) 

edited as should be a table:  facebook.login( appId, callFacebook, {“email”, “user_friends”}  ) 

should give me these permissions from the get go (i.e. without an initial call to facebook.login)

  1. the automatic “public profile”

  2. the requested “emal”

  3. the requested “user_friends”

But it only give me the automatic one and seems to ignore whatever you pass in as additional permissions.  Do you know what happens behind the scenes in the facebook plugin when you first login? 

Reading a bit further here:  https://developers.facebook.com/docs/facebook-login/permissions/v2.0#reference

It explains which permissions CAN be requested at the initial login:

  • Public Profile (default)  - public_profile
  • Friends - user_friends
  • Email - email
  • Extended Profile Properties  e.g. user_likes, user_birthday, etc

AND those that CAN’T - i.e do in fact require a second login / request:

  • Extended Permissions - Read
  • Extended Permissions - Publish  - publish_actions

(I have just listed the section headings)

I think (hoping? ;)  ) there is some confusion in the plugin code around this that can be resolved…

Hope all that makes sense!

Cheers

I just wanted to make sure the syntax is right on the parameter list.  I once saw it as { “perm1, perm2” } but that doesn’t make sense because we are passing a table, so ti should be { “perm1”, “perm2” } like you initially had it.

Hi Rob,

yes, I have it as a table - that’s my fault for copying and pasting while doing my post haha

In my actual code I have used a table i.e.

facebook.login( appId, callFacebook, {“email”, “user_friends”}  ) 

I’ve just updated my reply so as not to confuse anyone!

Right, but what I wanted you to do was try it as { “email,  user_friends” }, as a single string inside the table and also try it just asking for one of the permissions { “email” } and just humor me and see if it gets you any thing.  It should be { “email”, “user_friends” } but because I saw it the other way once, I want to double check it.

Rob

Hi Rob,

I’ve just tried something that was quite interesting…

First thing I tried was a single login with junk data for permissions like so:

function fbLogin(event) -- login to facebook and then get user data fbCommand = GET\_USER\_INFO --facebook.login( appId, fbLogin2, {} ) facebook.login( appId, callFacebook, {"junk1", "morejunk"}) -- {"email", "user\_friends"} ) end

When i ran the above, it just gave me one facebook screen with public_profile permission which I expected…

I then tried the double login process i.e.

local function fbLogin2(event) -- second login?? --facebook.login( appId, callFacebook, {"email", "user\_friends"} ) facebook.login( appId, callFacebook, {"junk1", "morejunk"} ) end function fbLogin(event) -- login to facebook and then get user data fbCommand = GET\_USER\_INFO facebook.login( appId, fbLogin2, {} ) --facebook.login( appId, callFacebook, {"junk1", "morejunk"}) -- {"email", "user\_friends"} ) end

Now when I run the code - I get the same initial facebook page with the public_profile only but when it tried the second login - I get an error on facebook saying “invalid scope: junk1” 

I was (a little bit… sorry) hoping for it to error because it suggests that the logic behind facebook.login completely ignores whatever you pass for the permission table whereas second time round it uses it.

Do you think there is a case to delve in to the source code and check?

Ah, sorry Rob - I misunderstood… No worries… happy to try whatever…(I’ll try with a single login request)

Ok, so when I try as a single string I just get the default “public_profile”

Doing just “email” or “user_friends” on its own also just gives me the default “public_profile”

This doesn’t suprise me given my test I did with the “junk” permissions.

Just for fun though…  If I do the double login process and I use the single string it does work. I then tried again with a table and that worked too! I correctly get email and user friends permissions displayed on the facebook second login screen

Maybe behind the scenes in the plugin it loops through the table element and appends them to make one string?  that could explain why either would work?  

Which facebook SDK does corona use in the plugin?

We just updated to the latest plugin about a month ago.

But you can get this working, with two logins correct?

Rob

Yes, using two logins it works but surely we shouldn’t need to do two logins for the read only permissions.

What was the update? is that currently just in the daily builds or is that an update on your end? i.e. will I be using the updated code already?