How to interpret the oauth expires=4 digit code upon receiving access token
In my application, certain clicks need to generate facebook post. I popup the facebook login screen if I have no access token.
Upon receiving the access token I also receive a "expires=4 digit number" at the end.
e.g. expires=3994
What does that 4 digit code mean?
Is it time in seconds after which the access token will e开发者_运维技巧xpire?
Or is it the number of ticks after which the access token will expire.
I have seen some facebook api code which expects 12 digit expires code but I am receiving only 4 digits.
The reason I need to know if the access token has expired is that I do not want my post to fail and would like to pop up the login screen if it has expired.
It is the no of seconds before expiry time. i.e.
3994 / 60 / 60 =~ 1 hour
If you see more digits (especially on canvas access link), it is probably a Unix time-stamp which you can convert to seconds easily. Also you can use below scope to get a non expiring token (but it will display an additional warning with the authorization popup window):
scope=offline_access
At my project (http://www.nbusy.com/projects/communicator) I use something like the below to know of the token expiry time:
DateTime eprityTime = DateTime.Now.AddSeconds(3994);
and compare it with DateTime.Now and close the session when token expires.
The token you receive initially from Facebook in the signed_request expires in 2 hours or 7200000 milliseconds or 7200 seconds. If you extend the token with the below request you will receive a new expire time of 5184000 seconds which converts to 60 days.
more on this answer here...Expiry Time of facebook access token
精彩评论