7

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?

Nakilon
  • 34,866
  • 14
  • 107
  • 142
user2070392
  • 111
  • 1
  • 2
  • 3
  • You can get a permanent token: http://stackoverflow.com/questions/17197970/facebook-permanent-page-access-token/17234650#17234650 – Josh Oct 25 '13 at 03:18

3 Answers3

2

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.

Community
  • 1
  • 1
Vlasec
  • 5,500
  • 3
  • 27
  • 30
2

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.

i3arnon
  • 113,022
  • 33
  • 324
  • 344
MaxVW
  • 47
  • 3
  • 4
    I think that the solution you are suggesting only works for app tokens, and not for user tokens. – rfc1484 Jul 23 '15 at 09:38
0

Shouldn't you be able to use the Page access token for the Facebook page itself? have one of the admins grant your app manage_pages permission, and then use the page access token to retrieve the photos from the page - the page access token won't expire if retrieved via the server side oauth process

There's a detailed guide to logging in as a page in the developer documentation -

Igy
  • 43,710
  • 8
  • 89
  • 115
  • I tried Page Access tokens too. Page access token also have 60 days expiration – user2070392 Feb 14 '13 at 20:15
  • Not if you retrieve the page access token using a 60 day token for the page admin which was retrieved from the server side oauth process, it should be infinite then – Igy Feb 14 '13 at 21:21
  • If you can reliably repro that not returning an infinite length page access token you should file a bug report – Igy Feb 14 '13 at 23:30
  • 1
    I followed following steps: https://www.facebook.com/dialog/oauth?client_id=&scope=manage_pages&redirect_uri= I got code from this API call. Then I got token as follows : https://graph.facebook.com/oauth/access_token?client_id=&redirect_uri=h&client_secret=&code= I verified the token using Access token Debugger. Token is valid for 60 days. To get page token, i used url: https://graph.facebook.com/me/accounts?access_token= I got token for my app page. I verified this token in tool, Its valid only for 60 days. – user2070392 Feb 14 '13 at 23:33
  • Please let me know if i ma following right steps to get the token. Thanks for your help "Igy" – user2070392 Feb 14 '13 at 23:34