I am facing some weird problem with facebook login. (android)
The very first time I call facebook.login_with_read_permissions (for a particular user), the facebook app shows the permissions required window. Then when the user accepts the permissions, I get status as “Aborted”.
The second time, however, everything works as expected, facebook does not ask for permission (because it was granted the first time) no window appears and I get the correct response.
The same thing happens when using facebook.login_with_publish_permissions.
This also happens when the user is logged out of the facebook app and logs in when the window appears.
local function get_me_callback(self, id, response)
-- The response table includes all the response data
pprint(response)
end
local function fb_login(self, data)
pprint(data)
if data.status == facebook.STATE_OPEN then
-- Logged in ok. Let's try reading some "me" data through the
-- HTTP graph API.
local token = facebook.access_token()
local url = "https://graph.facebook.com/me/?access_token=" .. token
http.request(url, "GET", get_me_callback)
msg.post(self.sender, "fb_login_success")
elseif data.status == facebook.STATE_CLOSED_LOGIN_FAILED then
-- Do something to indicate that login failed
pprint("Error!!")
else
pprint("Handle facebook app logout error!!")
end
end
function on_message(self, message_id, message, sender)
if message_id == hash("login") then
facebook.login_with_read_permissions(permissions, fb_login)
end
end
The output I get only the first time
DEBUG:SCRIPT:
{
error = Aborted,
status = 0,
}
DEBUG:SCRIPT: Handle facebook app logout error!!
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook
Another thing, when the facebook window appears, pressing back is not closing the window. It returns to the game for a second then reopens the facebook window.
Here I tried pressing back a few times
DEBUG:SCRIPT:
{
error = Aborted,
status = 0,
}
DEBUG:SCRIPT: Handle facebook app logout error!!
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook
What’s going on?