Token and App side
So to do this you will need to get the the relevant Access Token from facebook:
- User Access Token if you want to post things on their behalf and access information about them.
- App Access Token if you want to change app settings
You can read about it here but from what you have said you will probably want the User Access token.
After you get the access token you send it to your server using a unique ID for the user, this could be the device Serial Number or better the Google/Apple ID so that someone who sells their phone doesn't accidentally sell their account on your app as well.
When the app wants to do something with facebook it sends the request to your servers which then fulfil the request server side and possibly return something to the phone once they are done, the app could keep going doing more stuff and wait for a response in the background then inform the user.
Eventually the Token will expire, depending on exactly how you use the token your servers will have to check every account periodically, when they want to use it or when the user returns to the app. Once this happens you could try sending a push notification to the users phone or simply wait for them to return to the app where they will have to re authenticate with facebook in order to get a new token which is sent back to your server to replace the old one.
- User first logs into facebook to generate the Token for your app.
- Token is sent to your server along with identifying information
- Token is used to fulfil app requests (or whatever you want to use it for)
- Token expires and the user must re authenticate with Facebook and the new token is stored on the server.
SDK and server side
When you actually want to implement this you might not necessarily need the Unity SDK as that requires an appID to work. If you really want to use it you might have to find out where the AppID is stored and set it dynamically at startup before initializing the SDK. Otherwise you'll have make your own interface and pass all the login data through your server, if you do this use SSL to encrypt it when someone finds out that you're sending their login data without security you will not have a good week... Then once you have the data you do the query from your servers and give the app back the result (essentially a man in the middle between the app and facebook).
The servers would use the relevant SDK for whatever language they get coded in or just the web API since some languages (e.g. C#) have web handlers built in. You would need to build a REST API which can handle all the requests that you need the app to make. Keep security in mind here again because you don't want someone with a computer making random requests on the app's behalf, look into authentication techniques between your server and your app otherwise (again) you won't have a good week when (not if) somebody figures out your vulnerable.