Search code examples
ruby-on-railsfacebook-graph-apikoala

Koala support for multiple FB Apps at the same time?


I'm initializing Koala with one FB App's info (app id, secret, callback url) and that is the usual one that I need to use for making graph api calls.

However, I need to occasionally make calls within the same RoR process to the FB graph api for a different FB App. What's the best way to do this for one-off calls that I need to make for the 2nd FB App? I thought initializing a new object like this would work, but it still seems to be using the original app info:

k = Koala::Facebook::API.new(user_fb_token, APP_2_SECRET)

Ideally, it can support multiple apps at the same time so that I don't have to worry about other calls accidentally using the 2nd app if I re-initialize Koala.


Solution

  • Just in case it's still open - you can easily use Koala for several FB apps at the same time. The thing is that your user_fb_token is dependent upon app, not a general user token. It's actually user_fb_token_for_app_1, and user_fb_token_for_app_2. And then you create two instances of Koala for two different tokens.

    As a side effect, you would need to follow two login procedures for each app to get two tokens for the same user.

    Useful link: Access Token "debugger" by FB to see details on token:

    https://developers.facebook.com/tools/debug/accesstoken/?q=

    There you would see that user token actually belongs to specific fb app.