I'm working on web app which is NOT a Facebook Application.
I want to get current logged user's ID (I'm not sure if this is the right expression, I mean facebook.com/userid ) or user's name using Javascript.
Please if you don't know how to do it or if you don't have any suggestion what should help me, don't comment , thanks.How can I do this?
You cannot get the details (facebook id etc.) of the currently logged-in facebook user without using an app.
To query for the current user, you'll have to query for the /me and that requires an active access token which you can only get when the user authorizes an app!
Related
I am trying to create a login with facebook using javascript for a chrome extension that will return some data from the server.
I am currently able to login without issues with google and facebook. Google is returning the email address and an unique ID that only applies to my app so I can use that ID to login into my server together with the email address provided.
Facebook returns the real user ID and the email address, meaning that anyone that has access to facebook can find that ID and if they know the email address they will be able to login.
As I do not want to ask the user to login every time that they restart the browser or every few days, what is the best way to get a unique constant secure ID from facebook that is unique to my application?
Naturally if I make it unique in the extension it would not really be beneficial because anyone can read the extension code and then figure out how to get someone else unique ID from their user ID.
The authorization code that Facebook sends is not constant, so I would not be able to send it to the server to authenticate someone.
"Facebook returns the real user ID" - wrong, the api only returns an App Scoped ID. And no one except for the user himself will be able to login. Just use the App Scoped ID, that´s how you identify users in your App. Btw, user IDs are not really something you need to keep secret. Access Tokens are.
I am using passport.js to let users log in.
I am wondering if it's possible to create a link to their profile on their social media account?
For instance, when logging in using Facebook, I can get an ID, but the link https://www.facebook.com/profile.php?id=__ID__ doesn't work.
Maybe it's not possible at all since some Facebook users might have their Facebook profile hidden even though they use their account as login for other websites.
From what i know, this is not possible using passport at least.
The reason why the link doesn't work is that the ID returned by Facebook is always app specific so different apps would get different IDs for the same user. So you don't get the "official" ID of a user which you could use for building the URL.
However, the Facebook API returns a link to a users timeline which should be the one you are looking for (https://developers.facebook.com/docs/graph-api/reference/user/). But from what i see in the documentation of passport, this information is not returned. So if you want to get the link you need to work with the Facebook API directly.
I'm creating a firefoxOS application using jquery mobile and cordova.There is no api in cordova for integrating facebook and firefox applications.
I have created a app in facebook and since there is no platform for firefoxOS,I have selected "website" as my platform.The problem is that there is no url for my firefoxOS application(only index.html),that I can give as redirect url in app settings page of developer.facebook .And also the I have followed steps from this URL (//developers.facebook.com/docs/facebook-login/login-flow-for-web/v2.3) and its working fine in the browser as I'm able to login and share and get user details.
But when i copy/paste the code in my firefox project's index.html,the SDK does'nt seem to loading as none of the functionality is working.
Apart from the above trial,I have done the "login" flow manually by using this URL window.open("//www.facebook.com/dialog/oauth?client_id=APP_ID&response_type=token&redirect_uri=//MY_LOCALHOST/NAME/success.html").I'm able to access the current user's ACCESS_TOKEN from the success.html which is in server,but unable to access it in my index.html(as it is not hosted anywhere).I have tried to use localStorage,sessionStorage,cookies in success.html . I was wondering if there is any way of getting the current user's ACCESS_TOKEN after i have logged in.
I have used this URL https://graph.facebook.com/oauth/access_token?client_id=&redirect_uri=&client_secret=&code= (from //developers.facebook.com/docs/facebook-login/access-tokens) but it didnt help as I will be getting the access token which is redirected to success.html page which is in server.I need the ACCESS_TOKEN so as to pass as a parameter to this url https://graph.facebook.com/me?fields=id,name,email,picture&access_token=ACCESS_TOKEN in order to get the details of the user currently logged in .
But I'm able to share perfectly using this URL window.open("//www.facebook.com/dialog/feed?app_id=APP_ID&link="+encodeURIComponent(urlPost)+"&caption=&description="+encodeURIComponent(message)+"&redirect_uri=MY_LOCALHOST/NAME/success.html")with respect to the user logged even without the access_token (I dont know how its posting to the wall of the current user)
Is there any solution for the above problem? Thank you!!
I would like to let users login to my site using Facebook and I want to obtain a token from FB when the following properties:
For a given user, the token is always the same when they log in with facebok
The token is unique to my app. That is if that user logs into some other app with facebook they aren't given the same token.
Does FB provide anything like this? As far as I can tell the user id that the facebook api returns is the same for all applications.
I know that I could achieve #2 by sending the FB userID up to a server and hashing it with some secret key but I'm trying to make a purely client side application.
Facebook provides a field third_party_id (see: https://developers.facebook.com/docs/reference/api/user/), that is unique to your app.
It’s main purpose is to be used to identify a user without violating their privacy, f.e. when you would have to pass a user id around as a parameter in a public URL or something.
If you ever need to “translate it back”, you can use it to look the user up via the FQL user table (with an access token for your app only, of course).
I'm going more in depth in the Facebook javascript sdk but I am still new to it. I would like to display for every user on my website who logged with Facebook, their friends' pictures who also authorized the app. It is clearly and simply possible by using PHP SDK, but I only want to make use of javascript SDK to improve the speed of my site. Does anyone have an idea ?
Best,
Newben
You can use FQL to query the current user's friends SELECT id, name FROM user where uid IN (SELECT uid1 FROM friends WHERE uid2=me()) AND is_app_user=1. This query does two things. Finds all the friends and find only the friends who have your app installed.
For additional information see:
http://developers.facebook.com/docs/reference/fql/user/
and
http://developers.facebook.com/docs/reference/fql/friend/