Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook non-expiring access token

Tags:

facebook

token

I want to show the last facebook post on my website. I have a script for it but it needs access token to work.

I followed the steps mentioned in this post:

https://neosmart-stream.de/de/facebook/how-to-create-a-facebook-access-token/comment-page-1/#comment-617

Now I've got an access token with an expiry period of 60 days but when I open https://graph.facebook.com/me/accounts, I get this error:

{
   "error": {
      "message": "An active access token must be used to query information about the current user.",
      "type": "OAuthException",
      "code": 2500
   }
}

as my access token validity is 2 months, It is supposed to work.

like image 361
user1915882 Avatar asked Dec 19 '12 13:12

user1915882


2 Answers

1: Create an application in facebook with your website url

2: Run this link in your browser

3: Visit the following to generate a new SHORT-LIVED (1 hour) access token:

https://www.facebook.com?client_id=[APPID]&client_secret=[APPSECRET]&redirect_uri[http://APPURL]&scope=manage_pages,read_stream&response_type=token

4: Take that short-lived access token and send it here:

https://graph.facebook.com/oauth/access_token?client_id=[APP_ID]&client_secret=[APP_SECRET]&grant_type=fb_exchange_token&fb_exchange_token=[EXISTING_ACCESS_TOKEN]

5: Then, either in FB’s Graph API Explorer or on your own, visit here:

https://graph.facebook.com/me/accounts?access_token=[TOKEN]

Then paste the token and id in the code, then you will get the result.

You can debug and verify the expiration date of your token using the FaceBook Access Token Debugger:

like image 77
Tapefreak Avatar answered Sep 17 '22 21:09

Tapefreak


when i'll open https://graph.facebook.com/me/accounts...

You need to open it in the Graph API Explorer and add the access token retrieved in the earlier step or append it to end of the url

https://graph.facebook.com/me/accounts?access_token=XXXX

like image 30
phwd Avatar answered Sep 19 '22 21:09

phwd