2

I am getting the following response from facebook when using the ios fb library.

{"error":{"message":"Error validating access token: The session was invalidated explicitly using an API call.","type":"OAuthException","code":190,"error_subcode":466}}

I am using the below code to make this request:

facebook = [[Facebook alloc] initWithAppId:@"xxxxxx" andDelegate:self];

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
    NSLog(@"FB: taking saved token");
    facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
    facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}

if (![facebook isSessionValid]) {
    [facebook authorize:nil];
} else {
    NSLog(@"FB: session already valid");
}

[facebook requestWithGraphPath:@"me" andDelegate:self];

And below you can see some logging, some from the fb call backs, which i implemented:

FB: taking saved token
FB: session already valid
FB: didLoadRawResponse
FB: didFailWithError

I HAD previously revoked the app's access through the apps dashboard, so i was expecting the isSessionValid call to return false. However it doesn't and still believes the session to be valid. I must be misunderstanding the meaning of "session" here.

I have also tried calling extendAccessTokenIfNeeded to play nice with the new token system, however this achieved nothing.

So it strikes me this is a catch 22 situation, facebook tells me the token is good, but making a graph call fails. Do i need to somehow handle the universe of token invalid error codes and call authorize again?

Trying to find out using the facebook "documentation" was driving me gently insane.

How are others handling this issue?

EDIT 1:

I now get the following error, and cannot get the previous one, this may have been due to switching on the 'remove offline_access' migration.
However, fundamentally the issue is the same.

FB: {"error":{"message":"Error validating access token: User xxxxx has not authorized application xxxxxx.","type":"OAuthException","code":190,"error_subcode":458}}
0

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.