Search code examples
facebookfacebook-php-sdkfacebook-access-token

How to check the access token is valid or not without using appId and secret?


I have an access token. I want to check the access token is valid or not using php-sdk. Is anyway to check the access token is valid or not ?


Solution

  • The access_token can be used without using the App ID and Secret. You can simply make a API call to https://graph.facebook.com/me?access_token=xxx. If the access_token is valid, the user's information will be viewable. If the access_token is invalid you'll get an error:

    {
       "error": {
          "message": "Error validating access token: Session has expired on Mar 13, 2014 5:00am. The current time is Mar 19, 2014 8:25am.",
          "type": "OAuthException",
          "code": 190,
          "error_subcode": 463
       }
    }