Authenticate mobile user against Facebook SDK, make requests from server app

android, facebook, facebook-android-sdk

Solution

Yes, this is allowed by FB. See below:

https://developers.facebook.com/docs/facebook-login/access-tokens/#architecture

As noted above, access tokens are portable. This means that once you obtain a token, you can generally use it from any machine - server, client or otherwise.

Problem

I am building an Android app for a website that uses FB connect to link their user data with FB user data by FB id. When I allow the user to log in via Facebook's Android SDK, I get an access token for which I can request data on the user's behalf. I would like to send the access token to the server and have the server then request the user's id to create a local session and send me back the user data specific to this website. Does Facebook allow the access token to be used in this way (authenticate from device and then request data from the server with the same token)? The alternative is to use the SDK on the device to get the FB user id and then pass that to the server, but I feel it's not very secure to allow a session to be created with just a FB user id. This would be an easy thing to impersonate. What is the typical scenario for this use case (log in via Facebook SDK to create a session on your own web app where the user data is already linked)?

Original source