Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get long live access token from Facebook

As I understand it, recently Facebook has decided to remove the offline_access permission and has introduced a concept called long-lived access tokens which last a maximum of 60 days. Is there anyone who knows how to get this access token with the Facebook JavaScript SDK?

like image 982
Ananda Subasinghe Avatar asked May 06 '12 01:05

Ananda Subasinghe


People also ask

How long do Facebook 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.

How do I get Facebook access token that never expires?

In the Access Token Debugger that will open up, click on the 'Extend Access Token' button at the bottom of the page. A new access token should be displayed and the text above it should say that it never expires.

How do I get my Facebook client token?

You can learn more about obtaining a user access token by implementing Facebook Login for Android. You can retrieve the user access token by inspecting Session. getCurrentAccessToken .

What is a long-lived access token?

Long-lived tokens are valid for 60 days and can be refreshed as long as they are at least 24 hours old but have not expired, and the app user has granted your app the instagram_graph_user_profile permission. Refreshed tokens are valid for 60 days from the date at which they are refreshed.


1 Answers

There is a way to extend this to 60 days. described here: https://developers.facebook.com/docs/roadmap/completed-changes/offline-access-removal/ under Scenario 4: Client-side OAuth and Extending Access_Token Expiration Time through New Endpoint

Edit: In order to extend the access token you need to make the following request with your short lived access token:

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  
like image 175
Yan Berk Avatar answered Oct 07 '22 23:10

Yan Berk