I'm trying to use the C# wrapper for Facebook. If i authenticate the user and obtain the accessToken, I want to store the accessToken so that I can access my own personal Facebook stuff (like photos, etc). However, th开发者_StackOverflow社区e accessToken invalidates after a period of time. How can I ensure that it doesn't?
Access tokens for users can become invalid due to various reasons. In most cases, they can expire if it’s past the time specified by the ‘expires’ field (by default access token have a 2 hour lifetime). What many developers do not realize is that an access token can also expire if a user changes their password, logs out or if she de-authorizes the app via the App Dashboard. It is very important that your apps handle such situations. If your access token expires, you need to reacquire a valid access token. [1]
If you request and obtain the offline_access extended permission then you will receive a non-expiring access token. Even these non-expiring offline access tokens can be invalidated by some of the actions emaillenin describes (password change, app removal/de-auth)
Me I store the Facebook app/user access Token after he authorized my webapp.
Later, when user come back on is account in my WebApp I check if this User access Token in my appDatabase = the accessToken call with php-sdk like so:
$facebook = new Facebook($SimpleConnectConfig);
if ($facebook->getAccessToken() == $databaseFBuserAccessToken){
echo '<a href="'.$facebook->getLoginUrl($appArrayPermsScope).'">
Link a Facebook Account
</a>;
}else{
echo '$facebook->api($user.'/permissions','DELETE');';
}
de-Identified my Facebook App
精彩评论