I am working on an iOS application that uses Parse and Facebook.
To enter Facebook, I follow the instructions on this page: https://www.parse.com/tutorials/integrating-facebook-in-ios
Following the tutorial, I have this code that validates a cached session:
// check if this cached session is still valid? // does nothing if still valid - (void) validateCachedSession { FBRequest *request = [FBRequest requestForMe]; [request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) { if (!error) { // handle successful response LogObvious(@"Facebook session validated. No problem"); } else if ([error.userInfo[FBErrorParsedJSONResponseKey][@"body"][@"error"][@"type"] isEqualToString:@"OAuthException"]) { // Since the request failed, we can check if it was due to an invalid session LogObvious(@"The facebook session was invalidated. Announce logged Out"); // The persisted session is invalid. Logout! [self logout]; } else { LogObvious(@"The facebook session was invalidated. Announce logged Out"); // The persisted session is invalid. Logout! [self logout]; } }]; }
As shown above, if a cached session is invalid, it should cause a logout:
- (void) logout { [PFUser logOut];
To check it out. First, I signed up for my application using a Facebook account. Then I changed my password and ran the application again.
The application correctly recognizes that the session is invalid and a logout is called.
But when I click login again, the login function returns this error:
Uh oh. An error occurred: Error Domain=com.facebook.sdk Code=5 "The operation couldn't be completed. (com.facebook.sdk error 5.)" UserInfo=0x1e066140 {com.facebook.sdk:ErrorInnerErrorKey=Error Domain=com.apple.accounts Code=1 "Server refused renewal request with error code: 190" UserInfo=0x1d56df10 {NSLocalizedDescription=Server refused renewal request with error code: 190}, com.facebook.sdk:ParsedJSONResponseKey={ body = { error = { code = 190; "error_subcode" = 65001; }; }; }}
Why? Even if I exit the application and restart it. The application is now stuck in this state - unable to log in. Any help would be appreciated.
p / s: To be clear, this is my login function:
// to be called when user explicitly clicked a login button - (void) loginByFacebookWithPermissions:(NSArray*)permissionsArray { LogFunctionCalledObvious(); [PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) { if (!user) { if (!error) { NSLog(@"Uh oh. The user cancelled the Facebook login."); } else { NSLog(@"Uh oh. An error occurred: %@", error); [self logout]; } } else if (user.isNew) { LogObvious(@"User with facebook signed up and logged in!"); [self requestLoggedInUserInfo]; } else { LogObvious(@"User with facebook logged in!"); [self requestLoggedInUserInfo]; } }]; }
p / s2: OK, after more research, so it stuck in this state until I go to Settings-> Facebook to re-enter the new password. Is this the right behavior? should iOS6 promptly remind the user of a password change when I change my Facebook password to Facebook.com?