cprogrammer
cprogrammer

Reputation: 55

Facebook iOS SDK: session invalid on iPhone after logging out of Facebook from a desktop

I recently integrated Facebook support into an iPhone application that I work on. I'm able to log the user in and make API calls fine, but I recently noticed some strange behavior.

After the user logs in I store the access token and the expiration date in NSUserDefaults. Before executing Facebook API calls I use [session isSessionValid] to make sure the session is valid.

The problem occurs if the user logs into Facebook from a desktop and then logs out. [session isSessionValid] still returns YES, but Facebook API calls fail with the error:

"Error validating access token: This may be because the user logged out or may be due to a system error."

Is there anything that I am doing wrong, or is this a Facebook bug?

Upvotes: 1

Views: 1533

Answers (1)

Anatoly Lubarsky
Anatoly Lubarsky

Reputation: 3036

Even if you store the access token and the expiration date in NSUserDefaults, you need to validate them when the user enters your app each time, even offline_access permission access tokens might be invalidated for example when users change their password.

When your app is started you just need to make a call to graph API "me" and in case you get exception you need simply to re-authorize, then you proceed with regular workflow of API calls.

hope this helps

Upvotes: 6

Related Questions