My situation and what i have:
- Rails app (last version of Rails)
- Koala gem (last version)
- 1 (one) Facebook user (for example - it's me), and that is all, no more users (!)
- Page on a website without any FB login forms/similar stuff
Now situation:
I am creating page at one website, my code should pull last posts from my Facebook account and display it on that page.
What i have already done:
- I added Koala gem
- Then i created app under my developer account at FB and grant to that app full access to my profile (it the same profile - developer and from i want to pull posts)
- Then i created app access token from here (https://developers.facebook.com/tools/accesstoken) - when i debugged it, FB told me, that THIS token is a short-live token, that expire in 1 hour.
Then i created that code in my model:
oauth = Koala::Facebook::OAuth.new(APP_ID, APP_SECRET) new_access_info = oauth.exchange_access_token_info self.get_token <- here i pull token from DB new_access_token = new_access_info["access_token"] new_access_expires_at = DateTime.now + new_access_info["expires"].to_i.seconds self.update_all(:token => new_access_token) ***<- saving token in db*** self.update_all(:exp => new_access_expires_at) ***<- saving expiration of token in db*** @facebook ||= Koala::Facebook::API.new(self.get_token)
So, first time i put my short-live token directly in db, so my code can pull it from there, then, when i reload page, i got NEW, long-live token (it have expiration date 12/01/2015).
BUT! When each time i reload my page, i get NEW token but with SAME expiration date (FB's debugger says me the same, when i copied token from my page and paste it in debugger).
I even tried to do this in different days, because i read "somewhere" that token renovation period is one time per day, but:
Token ALWAYS different, but expiration date always the same.
What i need:
To renew that token or write the code so that the token is updated automatically without actions from my side, because there is NO login windows or something similar. It should work ONLY from serverside.
Any thoughts? Already read i LOT of info and similar questions, but most questions is related with user interactions, like logins in appropriate forms, etc, so - no luck :/
You can try this method.