Facebook login on iOs - returns 'loginFailed'

hi, 

Facebook is such dark magic to me, I wish I was a ninja at it but I’m not so appealing to those who are. I am trying to make my second Carrot integration. It seemed to work on on my other app, Gabbler, but for SevenMinutes, my fitness app, I try to ‘share’ an achievement that the user has earned using a “Share on Facebook” button.  After clicking that button I see the dialog to connect to my app on FB and share the achievement but after I say ‘ok’ (the prompt to continue to allow the app to access FB’s app system) I get ‘loginFailed’ returned from FB. 

Anyone encountering this issue? What gives?

I have verified that my setup seems proper. Here’s the code for my ‘share’ button:

local function postToCarrot(badge_name)

      print("posting "…badge_name)

        carrot.postAction(“earn”, badge_name)

        local alert = native.showAlert( “Congratulations!”, “Bravo on earning a badge!”, { “OK!” }, close )

    end

    local function onShareButtonTouch(event)

      print(“clicked share button”)

      --retrieve the badge we just earned

      for row in db:nrows(“SELECT * FROM workouts where id = ‘1’”) do

        badge_name = row.badge

      end

      facebook.login(“577131645672800”, function(event)

        print(event.type,event.phase)

          if event.type == “session” and event.phase == “login” then

          print(“event.type passed”)  

      

              carrot.validateUser(event.token) 

              --make sure badge_name is set

              print(badge_name)

              

              postToCarrot(badge_name)

          

          end  

      end, {“publish_actions”})

    end

help please! Need to update this app for Christmas!

Hi,

3 questions to help debug the issue:

  1. Is this on iOS?

  2. Do you ever login before this?

  3. What version of Corona?

hi, thank you :slight_smile:

Yes, it’s iOs7 (device testing now)

I haven’t logged in on this app from this device. I do have the FB app installed.

It’s the most recent public release

thanks,

Jen

do I have to specify publish_actions? I don’t remember having to before but maybe I need to now?

You are specifying publish actions.

What you should do is call facebook.login once with no permissions.  Then when you actually need to use the publish_actions permission, call facebook.login() again with publish_actions permission.  So it would look something like this:

-- User pushes a login to facebook button local function listener(event) end facebook.login(1234567890, listener) ... -- User pushes a share button local function shareListener(event) carrot.postAction("earn", badgeName) end facebook.login(1234567890, shareListener, {"publish\_actions"})

So in terms of usability, if the user earns a badge, they will automatically see the login popup and go through that process. Then if they want to share their badge, they can do so on a second button click. I guess what I was hoping to do was have everything kick off with one single button click. I suppose I could chain the events somehow?

hi, I actually just now put in a test button that simply has a login action and still get ‘loginFailed’ coming back from FB. Oy, gevalt!

 local function listener(event)

    print(“registering FB”)

    print(event.type,event.phase)

  end

  local function onClk()

    print(“btn Clicked”)

    facebook.login(“577131645672800”, listener)

  end

  btnTest = widget.newButton

        {

          label = “test”,

          id = data,

          onRelease = onClk,

          defaultFile = “widget_ios/button/facebookBtn/btn.png”,

          overFile = “widget_ios/button/facebookBtn/btn.png”,

          width=150,

          height=30,

          font = “HelveticaNeue-Light”,

          labelColor = {

            default = { 255,255,255 },

            over = { 255,255,255 },

          }

        }

        btnTest.x = 100

        btnTest.y = 100

        self.view:insert(btnTest)

What does http://docs.coronalabs.com/api/library/facebook/accessDenied.html return?

This refers to the iOS integrated facebook app settings.

hi, I get the popup, Facebook access denied. And I tested my Gabbler integration, it’s not working any more either, OMG! Here’s what console is telling me:

client ‘com.facebook.Facebook’ stopping significant location changes

Dec 13 09:43:17 Jens-iPhone backboardd[28] <Warning>: Facebook[3438]: Could not stat /private/var/mobile/Applications/9AC3B1AC-BA02-4A28-BC1D-8D4760D91EF6/tmp/etilqs_xbSMoog1BPScqtI: No such file or directory

Dec 13 09:43:17 Jens-iPhone backboardd[28] <Warning>: Facebook[3438]: Could not stat /private/var/mobile/Applications/9AC3B1AC-BA02-4A28-BC1D-8D4760D91EF6/tmp/etilqs_mLQffGi8ffQXByi: No such file or directory

Help, FB is throwing up in my console!

I think I’m going to need a simple sample project that demonstrates this issue along which the reproduction steps.

hi, sorry to be so needy. Most of the time I can sort things myself, this is so mysterious.

Here’s a link to a sample project

https://www.dropbox.com/sh/zhspx7u5awa0cc9/rBToSSfwbY

FWIW I just built the sample FB Connect project to my phone and with the SevenMinutes app id it does work fine. So my app appears to be properly set up in Facebook. I wonder if it’s an issue with Carrot at this point.

J

It seems to me that if you have never authorized your app before, then this line:

if facebook.accessDenied then

will always be true.  Now I can’t really test this since I can’t build against the bundle ID you have setup.   If you do the force login followed by the regular login, do  you get the error?

Rob

I’m having the same issue.  Using the sample app with my appId it works fine, but not using my app.  Have you figured this out?

hi, I gave it up and moved over to the Social Plugin. That makes posting to Facebook and Twitter easy, if slightly less streamlined. At least it works. However the Facebook piece of it doesn’t yet work on Android…going to revisit this next year :slight_smile:

best,

Jen

Hi @nahmeenstudios, can you tell me more about your situation:

What build of Corona are you using?

What device are you testing on?

Have you looked in your device’s console log to look for errors?  (See this tutorial if you need help finding the log: http://www.coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/)

Have you followed the advice in this tutorial? http://coronalabs.com/blog/2013/07/30/understanding-facebook-authentication/

Can you post  your code that you are trying to use to login to facebook?

Thanks

Rob

Hi,

3 questions to help debug the issue:

  1. Is this on iOS?

  2. Do you ever login before this?

  3. What version of Corona?

hi, thank you :slight_smile:

Yes, it’s iOs7 (device testing now)

I haven’t logged in on this app from this device. I do have the FB app installed.

It’s the most recent public release

thanks,

Jen

do I have to specify publish_actions? I don’t remember having to before but maybe I need to now?

You are specifying publish actions.

What you should do is call facebook.login once with no permissions.  Then when you actually need to use the publish_actions permission, call facebook.login() again with publish_actions permission.  So it would look something like this:

-- User pushes a login to facebook button local function listener(event) end facebook.login(1234567890, listener) ... -- User pushes a share button local function shareListener(event) carrot.postAction("earn", badgeName) end facebook.login(1234567890, shareListener, {"publish\_actions"})