How to get the logged in user's facebook ID? - facebook

I am using facebook connect to allow users to log-in to my site using facebook. I am using the server side authentication using OAuth in classic ASP, vbscript. I want to know if one of the following is possible:
1) Can I identify if the user has authorized my app without redirecting to the Auth dialog? ie, even before the user clicks the facebook login button to log-in to my site, is there a way I can find out if the user who is currently logged into facebook has authorized my app?
2) How can I get the facebook user Id of the user who is currently logged into facebook? This is outside the facebook authentication process. Does facebook offer some api which I can use to read the fb cookie that is set when a user logs into facebook and get the logged-in users's facebook user id?
Thanks

1) Use FB.getLoginStatus from the JavaScript SDK.
2) If he’s not connected to your app yet, then not at all. Otherwise, see 1)

Related

Can I used passport.js to login to Facebook from an app?

I and a friend are developing an app and would like to use Facebook as a way of users having their own accounts without us having to ask them to store passwords or make users for security and ease of use.
Passport.js has a facebook plugin but it talks about a redirect URL so my question is: is it actually possible to just send information like email address and password to facebook for authorisation and return the users profile without actually redirecting the user to a facebook login page.
I don't see how i could redirect the user to a facebook login while inside my app and also what on earth would i put as the callback URL? Am i just trying to use passport-facebook in the wrong way?
is it actually possible to just send information like email address and password to facebook for authorisation
No. Users are strongly discouraged from giving this information to any 3rd party app, and you are not allowed to ask users for them.
Login with username/email and password happens on Facebook, not in your app. You will get feedback from the login endpoint then that they logged in successfully.

How to start session in my web application after successful facebook login?

I am using Facebook login with the Facebook javascript sdk. I have implemented all the login flow. I want to know what I should to do to start a session on my application. From Facebook docs https://developers.facebook.com/docs/facebook-login/login-flow-for-web:
Once your app knows the login status of the person using it, it can do one of the following:
If the person is logged into Facebook and your app, redirect them to
your app's logged in experience.
If the person is logged into Facebook but not your app, prompt them with the Login dialog.
If the person is not logged into Facebook, prompt them with the Login dialog.
I want to work on the first one: redirect them to my app's logged in experience. But I do not know how to recognize the user and start the new session on the server so that he can access personal data. I thought a possible solution might be to send the accessToken received on the client to my server, then ask to Facebook's servers if that is a valid token, if so then start a new session for the recognized user, otherwise ignore the request. Is that a correct flow?

Facebook API Integration

I want to avoid second login on my web-application. I want from my users who want to signup in my web application, then he/she login from facebook account and installed my facebook application, application ask for some permissions Full Name, Contact list, Primary Email, Chat, Messages. now my web-application linked on his facebook account. after then he/she logout from facebook the facebook session is destroyed and browser is closed
when he/she wants to login after 1,2 days. I don't want that user login again from facebook because he/she already logged before and our application is already linked on his account.Is this is possible.
when he/she wants to login in my application so he/she can access chat/message and friendlist from facebook.
You should be able to use your app's access_token to make Facebook requests to publish graph requests but I don't think you can do everything you want. You need the user access token
https://developers.facebook.com/docs/facebook-login/access-tokens/

how can i log in my website seamlessly using facebook credentials , when i'm already logged in my facebook account?

how can i login my website using facebook credentials that too seamlessly , when i'm already logged in my facebook account in the same session or in another session. For example i'm logged in my fb and when i open website named rottentomatoes.com in the same session or in another session , i can get automatically logged in , without doing anything , as that site use my fb account and automatically get a registered memeber of that site.
i wanna do this things in my website , like things happening with rotten tomatoes.
so far i can use fb account to login in my website using facebook connect .
please help me ....any suggestion will be welcomed.
You need to have a facebook app, then in your site use the facebook js sdk.
You always have different sessions per site, you'll need to make a session for yours, you don't use the facebook session, just the sdk.
When the user loads your page you can use the FB.getLoginStatus to check if the user is logged into facebook and is authenticated with your app, if so then you get the needed user data and can then log the user into your site.
If the user is not logged into facebook, or hasn't authorized your app then you can use the FB.login method to log the user in, when the user comes back from that process you should have the data you need in order to register/log him into your site.

Facebook PHP SDK - Questions about accessing information / logging out

i want to connect a customer's website to Facebook using the PHP sdk (newest version). Visitors should be able to sign up using their Facebook account in order to be logged in automatically on the page itself if they are already logged in at Facebook, being identified by their profile ID which is saved in my database.
Here are my questions:
If I visit a website (which is using Facebook Login) for the first time, will this website be able to recognize whether I am logged in in Facebook or not, if I have not granted the permissions to the corresponding Facebook app yet?
If I have granted the permissions to the app and the page recognizes me as being logged in at Facebook, what does happen if I call the logout function of the PHP sdk? Will I only get disconnected from Facebook on the current page or will I get logged out on Facebook, too?
This was the case a year or so ago, but now - without permissions - you don't know who the user is. (Facebook authentication)
You will be logged out of Facebook too. (Facebook getLogoutUrl)