Ios – Parse with Facebook Login: Server refused renewal request with error code: 190

facebookfacebook-ios-sdkiosparse-platform

I am working on an iOS App that uses Parse and Facebook.

For the Facebook login, I am following the guides on this page: https://www.parse.com/tutorials/integrating-facebook-in-ios

Following the guide, I have this code that validate the 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 the cached session is invalid, it should call logout:

- (void) logout
{
    [PFUser logOut];
    // Over here we will show the login button again.
}

In order to test this. I first logged into my app using a Facebook account. Then, I changed the password and revisit the app.

The app correctly recognises the session is invalidated and logout is called.

But when I click login again, the login function is returning 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 terminate the app and restart it. The app will now stuck in this state – unable to login. Any help will 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, upon more investigation, so it stuck in this state until I go to the Settings->Facebook to reenter the new password. Is this the correct behaviour? shouldn't iOS6 promptly remind the user to change password when I changed the Facebook password from Facebook.com?

Best Answer

Your error sub code points to this

static const int FBSDKSystemPasswordErrorSubcode = 65001;

case FBSDKSystemPasswordErrorSubcode:
            case FBAuthSubcodePasswordChanged:
                if (subcode == FBSDKSystemPasswordErrorSubcode
                    || [FBErrorUtility fberrorIsErrorFromSystemSession:error]) {
                    userMessageKey = @"FBE:PasswordChangedDevice";
                    userMessageDefault = @"Your Facebook password has changed. To confirm your password, open Settings > Facebook and tap your name.";
                    shouldNotifyUser = YES;
                } else {
                    userMessageKey = @"FBE:PasswordChanged";
                    userMessageDefault = @"Your Facebook password has changed. Please log into this app again to reconnect your Facebook account.";
                }
                break;

You will have to message the user somehow to do this

Your Facebook password has changed. To confirm your password, open Settings > Facebook and tap your name.

or

Your Facebook password has changed. Please log into this app again to reconnect your Facebook account.

Related Topic