Home > Backend Development > PHP Tutorial > How Can I Extend Facebook Access Token Validity After Offline Access Deprecation?

How Can I Extend Facebook Access Token Validity After Offline Access Deprecation?

DDD
Release: 2024-11-25 01:18:25
Original
438 people have browsed it

How Can I Extend Facebook Access Token Validity After Offline Access Deprecation?

Extending Access Token Validity after Offline Access Deprecation

Facebook's deprecation of the offline_access permission has created uncertainty regarding the acquisition of long-lived access tokens.

Specifically, the documentation suggests that server-side OAuth-generated tokens will possess extended validity. However, this does not appear to be the case.

Addressing the Issue

The provided response presents two solutions:

Solution 1: Official Facebook PHP SDK Update (August 14th, 2012)

An updated version of the official Facebook PHP SDK includes a method named setExtendedAccessToken. Calling this method will create a new access token with a 60-day expiration period.

Solution 2: Custom Function

A custom function can be added to the base_facebook.php file in the Facebook class. This function, getExtendedAccessToken, retrieves a refreshed access token with a 60-day validity.

Additional Notes

  • Enabling "deprecate offline_access" in the Advanced settings of your Developer App is recommended.
  • According to the updated SDK, calling getExtendedAccessToken no longer returns the token explicitly. Instead, it is stored in the persistent data. To retrieve the new token, use the getAccessToken method.

The above is the detailed content of How Can I Extend Facebook Access Token Validity After Offline Access Deprecation?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template