Phonegap facebook API - facebook

I have installed the facebook API in phonegap but i have hard time making it work see link .The index.html file in the exemple folder has a login button that once taped opens the native facebook application on my device requiring email and password. After having authenticated me, it takes me back succesfully to my app.
Whenever i tap on the "getsession" button for exemple it shows me an alert saying "undefined". I want to know how to get the access token that is given right after the authentication process within my app and everything related to the session so i can perform other tasks?
Thank you

Related

How to implement facebook login with strapi in ionic

I am wondering how to implement facebook login with strapi in ionic.
My question is: I have a button that will go trough http://localhost:1337/connect/facebook and it should be opening the facebook app on my phone. Once I log in how do go back automatically on the app with the users information? I have seen that it stores on the db but I am missing something on how to go back to application.
Thanks
Once the user presses the login button, your app will redirect him to connect/facebook.
Which will open Facebook for login in and after facebook will respond with code in URL to the URL that you set in Strapi provider configurations.
So you should handle the response in your frontend, take that code and send it to http://localhost:1337/auth/:provider URL of the backend, which will respond to you with user data.
Hope it'll work fine for you.

Webpage is not Available - Facebook Login Integration

I want to integrate facebook api to help in the registration process in my website. It was working fine before - the standard fb login button appears, the pop-up window to login to fb was working, some of the user data are obtained. However after several trials with me modifying the code as the feature isnt fully integrated yet in my site, whenever I press the login button what replaces the fb login page is "This webpage is not available." I already retracted the modifications I made to the point that it was back to the version wherein it was working before. I also created another app and replaced the app id and secret key, still it displays the same message. I do not know what is wrong. Please help.
Update:
I uploaded the project files to another hosting site and it works! Could it be that the previous domain is now blocked?
Please read the other posts, dude... we're all waiting for the FB to fix the issue...

Facebook logout when not authorized

I'm building a public installation using an iPad, built as an iOS web app (using the "Add to Home Screen" functionality) which is going to allow users to share content on Facebook.
I'm currently logging the user in to Facebook and getting them to authorize my Facebook app when they click my custom share button. On a successful login, I open Facebook's Feed dialog and allow them to share. Once they have shared (or clicked cancel) I automatically log them out, making sure that the next user that uses the public installation won't be able to share to the previous user's Facebook account.
This all works well, but things get tricky if someone was to hit my custom share button, log in to Facebook and then not allow my app. This would mean that they have logged in, but as they haven't authorized the app, I don't have an access token, and so can't log them out (FB.logout() requires an access token).
Is there a way around this?
Or is there another way that I can log a user out?
Or is there a safe way to allow a user of a public installation (built in HTML) to share on Facebook and be automatically logged out afterwards? Would building a native obj-c app, and using Facebook's iOS SDK help?
The best I can think of is that if the user logs in but doesn't allow the application, they are told that they need to log out, and redirected to Facebook to be able to do this. However this offers them the chance to browse Facebook and (through shared links in their feed) the whole Internet - this isn't acceptable for our installation.
I solved this problem by creating a native iOS app, where the Facebook share link opened in it's own UIWebView. And once the sharing was complete, I deleted all session & cookie information, effectively logging the user out.

Facebook connect, auto prompt for login

I have added a login button to my site anad added scope to publish actions as per guide i found here: developers.facebook.com/docs/reference/plugins/login/ and this works fine but my question is: How can i have same function but this prompt to show to users without needing to click on the Login Button.
If user has not installed app, he would be prompted automatically to install it.
Thanks for any help.
Use FB.getLoginStatus of the JavaScript SDK to see if you have a user connected to your app visiting your page. If not, redirect them to the server-side auth dialog (using client-side auth would not be a good idea, since most browsers will block a popup that’s opened without any actual user interaction).

How to relaunch an app like facebook-ios-sdk does?

Question:
I am actively looking in the source code on Github's facebook-ios-sdk project myself but I was wondering if anyone already knows how to relaunch an app that sent an iPhone user to Safari, such that the user can come back after some work has been finished?
Example:
When using facebook to login, the original app is relaunched after the facebook login page has authenticated the user.
Motivation:
I would like to be able to do the same for youtube videos without having to completely lose the user. I don't want to use the standard webview approach because I don't want to provide extra space to first let the video load for the user and then have the user click the play button. I want to skip the play button and its associated click entirely! Instead I want the user to be able to click on just an everyday regular iPhone button and be shown the video with the navigation for coming back to the app via relaunch.
You need your app to register a "custom URL scheme". Then get the callback in the remote web service to return a URL with that scheme. iOS will then launch your application.
More (somewhat old) info available here.
A list of common custom URL schems on iOS can be found here.
Generally, as part of the OAuth login process, you supply a callback URL as one of the paramaters. What this does, is tell the remote server (YouTube), that on successful authentication, redirect the user to the supplied URL. If YouTube supports this (does it support OAuth?) then on successful user login within safari, youtube will tell users safari to redirect to the supplied url. If this url is a "custom URL scheme" it will cause your app to relaunch and you can handle the situation from there.