Get App user access token using Koala and Rails

893 Views Asked by At

I have a Facebook app and I can get both its User Token and App Token from this url: https://developers.facebook.com/tools/access_token/ In my Ruby on Rails application I am getting event information using the following code:

graph = Koala::Facebook::API.new(<My USER token from the aforementioned URL>)
fb_event = graph.get_object(facebook_event_id) 

The issue here is that the app User Token expires. I know this is the reason why it should not be put directly in the code, but for testing purposes thus far it's been sufficient. However, this is obviously not a good long term strategy.

How can I dynamically obtain this User Token? Is it similar to getting a user token for an actual user as opposed to an app?

1

There are 1 best solutions below

1
Norbert On

You can request a long-lived token and use it for testing purpose. https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension