Parse invalid session token (Code: 209, Version: 1.7.1)

user499846 picture user499846 · Apr 3, 2015 · Viewed 18.8k times · Source

I have just update both my Parse and Facebook SDK's (1.7.1 and 4.0 respectively) - both were an absolute pain to get working I might add!

However I now getting 209 errors when I try to log in with Facebook.

Here's an example of my code:

- (void)loginWithFacebook:(HMSuccessBlock)completion{
NSArray *permissionsArray = @[@"user_about_me",@"user_location",@"user_friends",@"user_relationships"];

// Login PFUser using Facebook

[PFFacebookUtils logInInBackgroundWithReadPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
    if (!user) {
        NSLog(@"Uh oh. The user cancelled the Facebook login.");
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Log In Error"
                                                        message:error.localizedDescription
                                                       delegate:nil
                                              cancelButtonTitle:nil
                                              otherButtonTitles:@"Dismiss", nil];
        [alert show];
        completion(NO, error);

    } else if (user.isNew) {
        NSLog(@"User signed up and logged in through Facebook!");
        if (completion) {
            completion(YES, nil);
        }
    } else {
        NSLog(@"User logged in through Facebook!");
           completion(YES, nil);
    }
}];
}

Which yeilds the following [Error]: invalid session token (Code: 209, Version: 1.7.1)

My initial thinking is that the issue is something to do with my code in the app delegate - on older versions of the facebooksdk I would apply the following code

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [FBAppCall handleOpenURL:url
              sourceApplication:sourceApplication
                    withSession:[PFFacebookUtils session]];
}

However I cant seem to find anything to replicate this in the updated version, hence my code being

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                      openURL:url
                                            sourceApplication:sourceApplication
                                                   annotation:annotation];
}

Any help would be greatly appreciated.

Answer

Ronaldoh1 picture Ronaldoh1 · Apr 24, 2015

Delete the app from the simulator or your phone, then rebuild and re-run the app. Sometimes an old token gets cached. I just solved this problem for my app.