Facebook SDK 3.1 - Error validating access token Facebook SDK 3.1 - Error validating access token ios ios

Facebook SDK 3.1 - Error validating access token


The Facebook account on the device has become out-of-sync with the server as well as with the App's/SDK's cache. This can be solved by calling the ACAccountStore method renewCredentialsForAccount, which will update the OS's understanding of the token state.

In the next update of the SDK, the SDK will automatically call this API when it receives a response from the server indicating that a token has become invalid. For the 3.1.0 revision of the SDK, applications will need to explicitly call this API. Here is a code sample:

ACAccountStore *accountStore;ACAccountType *accountTypeFB;if ((accountStore = [[ACAccountStore alloc] init]) &&    (accountTypeFB = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook] ) ){    NSArray *fbAccounts = [accountStore accountsWithAccountType:accountTypeFB];    id account;    if (fbAccounts && [fbAccounts count] > 0 &&        (account = [fbAccounts objectAtIndex:0])){        [accountStore renewCredentialsForAccount:account completion:^(ACAccountCredentialRenewResult renewResult, NSError *error) {            //we don't actually need to inspect renewResult or error.            if (error){            }        }];    }}

There are several options for where/when to call the API. The simplest place would be to opportunistically make the call on application launch, or on view load. One problem with this approach is that it will cause a network round-trip that is often unnecessary. Another option is to call it when a session change notification occurs, indicating that a session has closed. Also many applications fetch some basic information such as graph.facebook.com/me, at application launch time, and if so -- a call to this method in case of an error response may be a reasonable place to ask iOS to update its token status.

Hopefully this helps!


I'm just going to contribute another thing to check that caused me to waste 3 hours:Make sure your FB app settings do not have the 'Sandbox' option on if you're trying to login with a non-app-developer FB user...Maybe obvious, but could save others a few hours hopefully.


Try adding, if you haven't already, your iOS App Bundle ID in the settings panel of your Facebook APP as suggested here.

Hope this helps.