Multiple Facebook accounts tied into one app

2019-09-07 07:56发布

问题:

I'm trying to figure out to have multiple facebook accounts tied into my app. So that when different users login, they can access their individual facebook accounts.

I would like to have my app have it's own login. After a user logs in they have the option to connect their facebook account. But because there are multiple users I need to figure out how to associate multiple facebook accounts.

Here's what I got so far:

  1. Facebook Dialog Auth because SSO uses the Facebook App, thus only allowing one fbook account at a time.
  2. Server Side Auth because I would like the access tokens to last decently long (60 days) without each user having to relog into facebook when they use my app.

Here are my hangups:

  1. How do I reapply a token once the user has logged into my app (after already associating their facebook account). Is this the correct method? Can anyone provide a tutorial or code for reapplying a token?

    private Facebook mFb;
    mFb.setAccessToken(TOKEN);
    
  2. Can anyone provide code on how to setup Server Side Auth?

回答1:

For the new Facebook SDK 3.0b for Android (http://developers.facebook.com/android), we include a new sample called SwitchUserSample which might be a good starting point for you.

As at the time of writing (since the SDK is still in beta and on the 'preview' branch), you can find the sample's code in GitHub at https://github.com/facebook/facebook-android-sdk/tree/preview/samples/SwitchUserSample - and of course the sample (with project files) is also in the SDK itself.