agorapulse / grails-facebook-sdk

Facebook SDK Grails Plugin
http://agorapulse.github.com/grails-facebook-sdk/guide
30 stars 13 forks source link

How to get longer access tokens? #50

Closed confile closed 11 years ago

confile commented 11 years ago

I really like this plugin but I still face problems to get longer access tokens.

Can you sum up ways how to get a longer access?

Can I use the access token to get a new token?

Is there a refresh token?

Thanks for help.

benorama commented 11 years ago

Can you sum up ways how to get a longer access? Since a few month, you can't have lifetime access token from Facebook. By default, session access tokens are short-lived (1 to 2 hours). You can exchange them for long-lived (2 months) by using the ContextUser.exchangeToken() method.

Can I use the access token to get a new token? Short-lived (session) : yes. Long-lived (exchanged) : no (it will return the same token if you try to exchange it).

Is there a refresh token? No. Each time the user log in, you should exchange the short-lived to get a long-lived token and store it in your db (encrypt it!). Requirement: the user should come back at least once every 2 month, otherwise after 2 month, you won't have any valid access tokens for this user.

Note: all of this is not related to the Grails Facebook SDK Plugin but to the features of the Facebook Platform. You'll face those limitations with any other technologies.