Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook - permanent user access token

My company has a corporate facebook account where they post event pics in different albums. My requirement is to get all the photos from facebook albums and show in our corporate website. I am able to fetch the photos but the user access token is valid only for 60 days which means every other two months i will have to login into company's corporate facebook account, regenerate the token and update the token in my application.

Is there any way to generate to permanent access token? or is ther any way to regenerate the token at my application level ( without showing login dialog box)?

Is there any other way to fetch the photos without creating app?

like image 326
user2070392 Avatar asked Feb 14 '13 00:02

user2070392


People also ask

How long do Facebook access tokens last?

When your app uses Facebook Login to authenticate someone, it receives a User access token. If your app uses one of the Facebook SDKs, this token lasts for about 60 days. However, the SDKs automatically refresh the token whenever the person uses your app, so the tokens expire 60 days after last use.

What is access token lifetime?

When issued, an access token's default lifetime is assigned a random value ranging between 60-90 minutes (75 minutes on average). The default lifetime also varies depending on the client application requesting the token or if conditional access is enabled in the tenant.


2 Answers

Your question is about user access tokens. I'm afraid those can never be permanent. However, from your discussion with Igy, you you seemed content with getting page access token. See my Q/A there:

facebook: permanent Page Access Token?

Lookup Graph API for /{pageId}?fields=access_token, using User Access Token that has manage_pages rights. The resulting Page Access Token should be permanent.

like image 198
Vlasec Avatar answered Oct 19 '22 19:10

Vlasec


moving to Oauth 2.1 it is actually MUCH simpler - use your App ID + App Secret as access token you can then access the feed (etc) via https://graph.facebook.com/v2.1/theO2/feed?access_token=app_id|app_secret

(from Facebook documentation on Access Tokens)

There is another method to make calls to the Graph API that doesn't require using a generated app token. You can just pass your app id and app secret as the access_token parameter when you make a call:

http://graph.facebook.com/endpoint?key=value&access_token=app_id|app_secret The choice to use a generated access token vs. this method depends on where you hide your app secret.

like image 32
MaxVW Avatar answered Oct 19 '22 21:10

MaxVW