Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook access token invalid with message "session does not match current stored session"?

I have recently started getting this error while posting to facebook newsfeed stream of an app user, I do have an offline access permission for the access tokens, and they worked fine previously. This error is coming for 30-40% of the users.

"Error validating access token: Session does not match current stored session. This may be because the user changed the password since the time the session was created or may be due to a system error." 
like image 977
DhruvPathak Avatar asked Jun 06 '11 05:06

DhruvPathak


People also ask

How do I fix an invalid access token on Facebook?

Please click on Facebook Ads Extension, Manage Settings, go to Advanced options and click on Update token.

What does error validating access token mean on Facebook?

Message: Error validating access token: The user is enrolled in a blocking, logged-in checkpoint. This error message means that your Facebook user account has failed a security checkpoint and needs to log in at Facebook or the Facebook Business Manager to correct the issue.


2 Answers

It's possible for your access token to become invalid for a variety of reasons (expiry time passed, user changed password, user deauthorized your app, user logged out of Facebook, etc.). You should always design to account for this scenario.

If your users are active, it's easy to get a new access token from the OAuth endpoint without them having to do/see anything. If not, you should make a plan (such as emailing them) for how you will get them to return so you can get a new access token. The scenario you're describing is not necessarily unusual. You can find some code samples here for help on how to handle expired access tokens.

like image 65
Jeff Bowen Avatar answered Oct 05 '22 23:10

Jeff Bowen


This is undocumented but I just tested it and it works with expired access tokens. Should work on access tokens that have been invalided if you know their user id, and they haven't revoked privileges to your app. First, you can verify that you still have have the permissions you need by calling using this url:

https://graph.facebook.com/userID/permissions?access_token=appID|appSecret

If you still have publish_stream permissions, you can issue a HTTP POST to this url:

https://graph.facebook.com/userID/feed with post parameters of access_token=appID|appSecret&message=test message

like image 37
bkaid Avatar answered Oct 05 '22 21:10

bkaid