Is there a way to check if Facebook access token is still valid?

Viewed 91016

My site utilizes lifetime access tokens (offline_access). However, if the user changes his/her password, the access token gets reset. Is there a method to check if the current access token is valid before making calls to the Graph API? Thanks for your time.

10 Answers

I went through these posts, bud I found very good solutions like this:

GET graph.facebook.com/debug_token?
    input_token={token-to-inspect}
    &access_token={app_id}|{app_secret}

Response from this request provides you everything you need:

  • your app ID - this verifies that token is from your application
  • application name - which can be also checked
  • expires_at - token expiration time
  • is_valid - boolean for check up
  • user_id - which you can also compare and check

Just note that "|" sign must be there as a letter

Related