facebookarchive / php-graph-sdk

The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login. https://developers.facebook.com/docs/php
Other
3.17k stars 1.95k forks source link

Permanant Data Access Token ? Programatically renew DataAccessToken ? #1199

Open daslicht opened 4 years ago

daslicht commented 4 years ago

Hello is there a way to generate a permanent access token using the SDK ?

When i verify my generated tokens it says:

Expires | Never
Data Access Expires | 1603117184 (in about 3 months)

Does that mean it is not permanent ?

ceejayoz commented 4 years ago

https://developers.facebook.com/docs/facebook-login/auth-vs-data/

The expiration period for data access is 90 days, based on when the user was last active. When this 90-day period expires, the user can still access your app — that is, they are still authenticated — but your app can't access their data. To regain data access, your app must ask the user to re-authorize your app's permissions.

daslicht commented 4 years ago

Thank you very much for the reply ! To the token expiration date is reset on each usage ? eg by reading events ? I am creating a solution for a client. The facebook app essentially is just used to generate the access token so that we can read all his page events. The app will not be shared with others. So there is no way to create a permanent token ?

daslicht commented 4 years ago

I just did some further research. When I do a api call something liek this:

            $response = $this->fb->get(
              '/somepage/events?fields=cover, description,name, start_time, end_time', //Get events and specified fields
              $this->access_token
            );

This should reset the expiration of the data_access token, but it doesn't. Or how is the user activity measured ? How to trigger user activity ? What counts as user activity ?