Announcement Announcement Module
Collapse
No announcement yet.
Using a Facebook token received from a native iOS/ Android client Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using a Facebook token received from a native iOS/ Android client

    Hi,

    We are already successfully using Spring Social Facebook to register/ login users to our web server.

    We are now developing mobile native apps (iOS/ Android) on top of our web server. In the apps we would have the facebook SDK login the user to facebook and then we will have a Facebook Token. We would like to pass this token from the native app to our web server. We need the server to use the token to call the Facebook API and get user info and then we would create a local account for the user on our server. If such an account already exists, we would just use the token to login the user into our app.

    My question is: How would we handle the received token so that it is used by the Spring Facebook infrastructure? We need to plug it into the flow we already have for Facebook Connect via the web. Any ideas?

    Also, can a token that was generated on the client (iOS/ Android native Facebook SDK) used on the server?

    This thread discusses this vaguely: http://stackoverflow.com/questions/4...s-a-secured-we but is rather old.

  • #2
    Without digging too deep into the details, you can take the token you get from the client and use it to create a new connection via the connection repository. Of course, you'll also need to know which use the connection belongs to. In the end, the code will look *something* like this:

    Code:
    UsersConnectionRepository ucr = ...; // probably injected
    ConnectionRepository cr = ucr.createConnectionRepository(userId); // you determine the userId somehow
    ConnectionData cd = new ConnectionData(...); // lots of params...you'll fill those in.
    FacebookConnectionFactory fcf = ...; // create or inject this
    Connection<Facebook> conn = fcf.createConnection(cd);
    cr.addConnection(conn);
    As you can see, the code above is rough...I'm leaving a lot for you to fill in. But that's roughly how you'd do it.

    Comment


    • #3
      Hi Craig,

      Thanks for the answer. Do you have experience (recent) in using a token received on the iOS/ Android Facebook SDK from the server? Would that work?

      Thanks!

      Comment


      • #4
        I see no reason why sharing tokens in either direction would not work. It's a "bearer" token after all, meaning that anyone who has (e.g., "bears") the token can use it.

        Comment


        • #5
          If I could make a transient Facebook connection by providing the Facebook user Id, access token and then get the email address of the FB user (I user email address as userId). Then I can persist the connection (I can do that directly to the DB).

          So is there a way to create a transient Facebook connection using facebook user id and access token ?
          Last edited by checklist; Aug 30th, 2013, 04:05 AM.

          Comment


          • #6
            I'm left unclear what "transient" means in this context. But you can certainly create a connection and then whatever you want with it. See the JavaDoc for OAuth2Connection: http://static.springsource.org/sprin...onnection.html. You'll probably be most interested in the constructor that takes a ConnectionData.

            Comment

            Working...
            X