Is it possible to retrieve an user id before agreeing to give permissions to an application?
I'm trying to salute a user before agreeing to the permission request. But for that I'll need to know his/her user id so I can access the info via graph API.
The idea is to do it when he/she is visiting for the first time my page app.
http://apps.facebook.com/xxxxxxxxxxxxxxx
Any idea?
This is NOT possible. Facebook WILL NOT share the user id with any app without the user explicitly allow that (partners are always a special case).
No it is not possible.
The only way to get the details of the current user is to issue a request to
https://graph.facebook.com/me?access_token=ACCESS_TOKEN
But here the problem is to get the access token, user should allow the application first.
Related
I have a desktop app which uses a user access token to read the me/feed endpoint and I can see all the posts for the logged in user. If I wanted to simplify deployment to different users I would need to minimise the amount of setup/configuration they did.
Is there a way to access me/feed for a given userid rather than have to setup every user as a developer account and create an app for it?
I have looked at https://developers.facebook.com/docs/graph-api/using-graph-api/v2.0 and it is not obvious to me how to do this.
What configuration / permissions does the user in question need to do to activate this. Which access token should I be using, and will it give access to all the posts in the same way the user access token does.
[EDIT] I have looked at this again and the problem I am having is that when a user (who has a facebook account but is NOT a developer) tries to login to my App (which is in development mode) I get the following error
"App Not Setup: The developers of this app have not set up this app properly for Facebook Login."
Thanks in advance
I'm trying to implement facebook connect to my website, and i have couple questions.
1: Is it possible to register user in my website using his current facebook email/password.
Let's say user clicks on link Register via facebook and then he have to give me permisions to access his password, email, etc... and after that is done i put that info in my own database and he will be able to login with that account any time he wants without needing to give me permisions any time in the future.
2: If that kind of registration is not possible, what's other solution would be the best for me? Because i need to somehow keep track of that user who logged in with facebook, because he can upload photos, send messages etc.
Anyways, i'm quite new with facebook and similar things, so i'm really lost here, hope some one can help me :)
EDIT Thank you all for wonderful answers it helped me a lot, now all that's left is to read documentation :)
Yes it is, it is possible to get the information of the user. But it is rather complicated, when you have never dealt with it.
First you need to send the user to the following link:
https://m.facebook.com/dialog/oauth?client_id=your-client-id&redirect_uri=xxx&scope=listof-information-you-want
Facebook will then return your client to the uri specified, if the user rejected it will give a reason. If it is not you will get an code in urlencoded format.
This code is needed for the following step, the request of the access token:
https://graph.facebook.com/oauth/access_token?redirect_uri=xxx&client_id=xxx&client_secret=xxx&code=xxxx
This will give back an access token, if the authorization didn't fail.
After that you can ask for the information you want:
https://graph.facebook.com/me?method=GET&metadata=true&format=json&access_token=access_token
This will include a facebook uid, which is unique for all users. Store it and you can discern between a register and login.
This is roughly the process for any oauth2 application.
Facebook will not ask repeatedly for permissions after the user granted them to you. So you can store the access token and reuse it for backend stuff and also use the same procedure you use for register for login.
You can never access the user's password from Facebook even with his/her permission, so the user will always have to authenticate via Facebook and have Facebook pass you the user id of the logged in user once authentication succeeds. You can store all kinds of other data locally, but not enough to authenticate the user yourself.
Once the user is authenticated, you'll have access to the user's Facebook user id via the API, which should be enough to connect all kinds of information to that specific user.
Facebook does not provide access to accounts when passwords are taken from your controls. It provides it own canvas for login information. Therefore you cannot use your first approach to store passwords in your databases. Check this out.
You can however store email addresses once user logins into his account using the facebook sdks. Check this out link for the example of C# SDK sample code.
You can use the Facebook APIs to fetch user email-id, photos, friendslist and other information and then play around accordingly.
You don't get access to the users password - only email if you ask for it.
Best way would be to have a table of users and their Facebook account id's.
If you want to allow users to sign up without Facebook then have a nullable field for their password and facebook id, and also have a field for username - which you could populate from Facebook if they register via that route.
I work for an organisation that is partnering with another group. Each of us will have a body of users logged into Facebook. What we want to do is to make it possible for a user who is signed in under my group's app id to see all his/her friends some of whom will also be logged in under that id, some of whom will be logged in under the partner org's app id.
The idea we had in mind was that it might be possible to grant permissions on auth to both app ids in one go. Is that possible? If not, does anyone have any idea how we could share this kind of presence data without also sharing all other user details?
No, that's not possible, though I don't see why you can't just use the same App to have multiple pieces of functionality
I'm using an fb login button on a site, and our app needs extended permissions: publish_stream. When the user logs in, we can get the permissions, get an access_token, and publish various items to their stream.
However, the site doesn't seem to know if the user's logged in to facebook or not, and I'm having to allow permissions on subsequent visits to the page. However, if I hit the website, I get the access_token - but I'm the admin of the facebook app.
Is there a way to get permissions and have them persist, or am I doing something wrong?
It sounds like you might need to request the "offline_access" extended permission (if you want to make API calls after a normal access token would have expired). I'm not sure this is what you need though - this is for making API calls as a user while the user is not logged in to Facebook anymore.
It sounds like your Application is not properly using the API to check if the user is logged in or not. Without seeing any code I can't tell what is happening, but if you are using the API correctly once a user has authorized your application, they should be able to make API calls via your App while they are logged in to Facebook. Unless you changed application's on them, they will not need to re-authorize the permissions.
Please edit your question to provide more details if this does not help, and good luck.
I want be able to send a list of friends & recent additions from someones facebook account to an email address daily or weekly.
Looking up online, I think the best approach would be to setup a website, where a user would facebook connect with their facebook credentials & accept all terms including accessing their friends list. The website would then run a batch job nightly to access that persons friend list, do a matchup and then send an e-mail with the summary of their findings.
Is this possible? Can I just do a onetime login and get forever access to someones friend list, assuming they do not manually revoke access to the application within fb? looking for suggestions. I know there is way to access a profile offline, but how long is that session available for? I know the policy has changed, AND can change in the future by trying to understand the current state of accessing a friends list offline.
Also, am I violating any policies by doing this?
You need to ask the user for an offline_access permission and read_friendlists permission, that way you'll get an accessToken that does not expire.
More info here: http://developers.facebook.com/docs/authentication/permissions
as long as you don't save data you'll be fine