Getting "Error validating access token" from Facebook for some users
Asked Answered
L

1

9

I'm getting the following error from Facebook when trying to post to a users stream.

Error validating access token: The session has been invalidated because the user has changed the password or because auth.expireSession was called.

The workflow is as follows:

  1. Authorize with Facebook requesting scope=offline_access,publish_stream permissions (if the current user has not already authorized)

  2. Do some work on the server (takes 5-10 minutes)

  3. Attempt to publish to the user's Facebook stream

This code works for many users, but for some users, I get the Error validating access token error. It started frequently happening a few weeks ago, then seemed to stop, and now happen a lot again. I'm certainly not calling auth.expireSession on my end, and it seems unlikely that multiple users would be changing their password in the 5-10 minute window from authorizing to publishing. Does anyone know what might be causing this?

Letaletch answered 12/5, 2011 at 3:8 Comment(3)
I'm not sure, but it maybe that the user "removed" the publish stream permission from your App? also it's always a good idea to update your access_token even if it's taken with offline_access.Colorist
Are you monitoring the Deauthorize Callback to see if users are uninstalling?Chandachandal
@Jason I'm not monitoring, but it seems unlikely that a user would grant my app access, then deny access within the next 5-10 minutes. It seems even more unlikely that lots of users would do the same thing within a few day period. Either way, the issue seems to have gone away so I'm guessing it was a temporary FB bug.Letaletch
B
8

Anytime you get this error, you should run the user back through the auth flow. There are many reasons that either the user or we will invalidate a session. We have a how-to on this at https://developers.facebook.com/blog/post/500

Bartram answered 30/7, 2011 at 0:20 Comment(3)
Thanks for the response. This actually stopped happening a few days after it started. However, re-authing the user wouldn't work in this case since the publishing is happening as part of a background process.Letaletch
your app still needs to take this scenario into account. you can send the user an email, whatever to run them through the auth flow again.Bartram
Link given you is not available.Agonized

© 2022 - 2024 — McMap. All rights reserved.