Ponsuyambu
Ponsuyambu

Reputation: 9006

How to ensure Facebook access token in API does not expire after two hours?

I have searched in Facebook docs to post user's feed by getting access token. But they mentioned that after two hours access token has expired.

My need is to post on my news feed using FB Graph API with one time user approval.

I have seen many applications which posts updates on my wall daily. I have given rights once only. But even I give full rights to my app, access token has expired in two hours. How can I do that in my app?

Upvotes: 0

Views: 771

Answers (2)

Tebe Tensing
Tebe Tensing

Reputation: 1286

Make sure that ‘Deprecate offline access’ is enabled for your app.

You can find the setting from Edit App > Advanced > Migrations tab.

Its enabled by default for any newly created app. Once enabled your access token will be long lived (validity of 60 days).

Upvotes: 1

DavidB
DavidB

Reputation: 2234

You don't have to authorize the app more than once, it's just that your app is going to have negotiate a new access_token when it expires. This is done using the cookie and a "code" which is in that cookie as long as the user is logged into facebook. I suggest reading this documentation very closely as it outlines how you do the "oauth dance" to create access tokens either client or server side.

https://developers.facebook.com/docs/authentication/

Upvotes: 0

Related Questions