Provide access token

In my application, I need to load the user’s Facebook friends. This answer addresses how to do so, however I find it’s an unflexible solution.
Would it be possible to share the access_token is with the client application? This way the client could do its own queries against the respective API.

The client SDK is open-source. Have you looked to see if there is a way for you to modify it to get what you need?

I looked into the code but as far as I see, the client never gets the access_token from the server so there’s not much I can do.

When you login with Facebook SDK, access token is right in the method signature.

And if you’re not using the Facebook SDK?
I’m using

Backendless.UserService.getFacebookServiceAuthorizationUrlLink()

What do you do with that URL once you get it? At some point you’d be receiving a token from FB, wouldn’t you?

Yes but that URL contains a code, not an access token.

I read that I can exchange a code for an access token, so I’m currently building a custom service that provides a method to do so.

Michel,

It appears you’re doing something not “main stream”. Could you please describe your use-case so perhaps we could make improvements for other users like you (yourself included) in the future versions of the SDK/service?

Regards,
Mark

I have an application (Java, cross-platform so I’m not using the FacebookSDK but facebook4j) that allows Backendless-login via Facebook. In this application I would like to load the user’s Facebook friends (or access any other FB API).

I understand that the solution I found with Backendless - and maybe I’m wrong here - seems to only load friends when the user is authenticated and not “live” from Facebook.

But since I would want to any Facebook Graph API anyway (or Google, or Twitter) without going over the Backendless server, I need the access_token on client side.

Maybe the solution is to do the FB login completely client-side and then use the access_token to log into the backendless server, like this code in the backendless.jar does:

          FacebookBundle facebookBundle = new FacebookBundle( response, accessToken );
          Object[] requestData = new Object[] { Backendless.getApplicationId(), Backendless.getVersion(), facebookBundle.socialUserId, facebookBundle.accessToken, facebookBundle.expirationDate, facebookBundle.permissions, facebookFieldsMappings };
          Invoker.invokeAsync( UserService.USER_MANAGER_SERVER_ALIAS, "loginWithFacebook", requestData, responder, new AdaptingResponder( BackendlessUser.class, new BackendlessUserAdaptingPolicy() ) );
        }
      } );

This is not yet a public API however.

I see now, thank you for the explanation. Here’s where access token comes from:

http://support.backendless.com/public/attachments/c5d91be0e2dd2436f20d2b884c3ad549.png</img>

So the logic you suggested - logging in to FB on the client side will get you want you want. See the code we have in the SDK and use it as guidance to get the token.