Senči
Senči

Reputation: 941

How do I check when a fb-token will expire

is there a possibility to check when a fb-token will expire?

I've read Authenticating as an app and Handling invalid and expired access tokens and searched the interwebs for an answer but I couldn't find any.

Regards, Senad

Upvotes: 1

Views: 1723

Answers (3)

Rahil Arora
Rahil Arora

Reputation: 3674

The good news is, there's an endpoint for it now.

You can retrieve the information related to a particular Access Token by issuing a GET request to the debug_token connection. Something like:

GET /debug_token?
     input_token={input-token}&
     access_token={access-token}

You can get more information about it in the Getting Info about Tokens and Debugging reference.

Upvotes: 4

complex857
complex857

Reputation: 20753

Unfortunately there's no specific endpoint that will tell you if an access_token is still valid or not, but you can use the token to fetch anything and see if it return an error or not.

However if you are using the server side flow for authentication, they will send you an expire parameters that will hold the time in seconds that the token will remain valid (the sdk may hide this fact from you).

But as the Handling invalid access tokens page explains, there's a number of reasons why an access_token can go invalid so the expire field alone won't be able to tell you if the token is valid at the moment or not, so the only way to find out is to try using it and see if its returns an error, as the Handling expired... page states, you will have to be prepared for any graph request return errors.

Upvotes: 2

Jonathan Dean
Jonathan Dean

Reputation: 1112

You can manually check it here for a given access token: https://developers.facebook.com/tools/debug

Upvotes: 0

Related Questions