How to implement facebook login with strapi in ionic - facebook

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.

Related

Facebook sdk4 php switch User feature

I am developing a site to manage Facebook Feeds and is using facebook-php-sdk-v4-4.0-dev.I have the user Login and access token saved to database functionality working properly.
I need to show Switch Facebook User account Option, If he is already logged into facebook account. Currently if he is logged into facebook account on another tab. There will not be facebook authentication, It just shows App Permissions window and then completes facebook login process.
But I found that this option is available in Facebook Login for the Web with the JavaScript SDK example...A pop up come up for Login and you can switch user on top right side.
Please let me know how to accomplish this in PHP sdk 4 or work around, or am I missing something here.
Thanks in advance....
Please see this screenshot
https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-xpf1/t39.2178-6/10574702_711575178930859_1600770327_n.png
I have added a screenshot where JavaScript SDK show switch user button (top right side)when user is logged in to facebook account in another browser tab.(this comes up as pop up)
But there is no such option when using php sdk. instead of pop up, its come as a webpage and it does not have switch user account.

Mobile Website Facebook Login using Facebook App for login details

Using a web browser e.g. Chrome on Android, if a mobile website requires a user to be logged in to Facebook and they are not, the browser will ask for Login details even though the phone may be logged in to Facebook via the Facebook native App. Is there any way to get details from the Facebook App without the user having to log in again?
If you want to login in website in a browser, using Facebook account from Facebook app - it is impossible, without intermediary application, or service. And even with it, I don't think, that you can get user login data.
Other approach - is try to launch Facebook app from your site, and show site from it, but again, you can't login to it, using app.
Why? Because the app, holds only token data, and nothing more. You can't get other information, like password, or email. Also, the work of browser, that save cookies and the app, that save token is different. You can't connect them together.
Clearly speaking it is not possible using website in browser.
Even it is also not possible if you develop any android app, the reason is that the facebook app will not share any data to any other app (even if it is running on the same device).
I also don't think that launching the facebook app from browser will be feasible for you, as you just want to use the facebook login system and then want the users back on your website (and again facebokk will not send any data to your web or app even if it is launched from your web or app).
I think it's not possible, because we wont link browser and an app.
I developed one android app with facebook login integration.If facebook native app already logged in, now i click my app facebook login button it directly redirect my app to my home page without asking fb username and password.
For me i used localStorage in javascript
localStorage.setItem("userName", userName);
localStorage.setItem("password", password);
var uname=localStorage.getItem('userName');
var pass=localStorage.getItem('password');

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.

Phonegap facebook API

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

How to call back to the application from Safari browser when successfully logged in?

I am using webservice in my app. I have set one button login with facebook button, that drag user to safari browser and open facebook login page. Here I have not used Facebook API, all things are coming from PHP side,
now I need the user back to application which is in background when he successfully Logs in..
I have set my URL schemes as "myapp" and when user logs in successfully in PHP side I have set url to open is "myapp://" so I can get back to my app.
But here problem is when ever url "myapp://" gets called it automatically converted to "http://domainname.myapp://" so safari is not letting the user to go back to application and it stays on the bowser.
where I am getting wrong?