Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Please login to this app again to reconnect with Facebook - error code 190

We are using:

Parse - 1.8.3 FBSDK.* - 4.6.0 ParseUI - 1.1.6 ParseFacebookUtilsV4 - 1.8.3 IOS Target - 9.0

Here is our issue. A user is logged into the app fine. They go into Facebook.com->Account->Settings and deauthorize the app (remove it entirely).

When the user launches our app again, they are greeted with a dialog from the FBSDK that says "Please login to this app again to reconnect with Facebook" (options are OK and Cancel).

I have googled/SO this and seen others with this issue, but in their case it is slightly different (and perhaps functional). This is because, when you click "OK" in that dialog, it does nothing. It appears that clicking ok is supposed to go do a login flow (which would be stellar), but again - it just does nothing.

I have tapped into the Notifications broadcast by the FBSDK and can see that I get a notification for:

com.facebook.sdk.FBSDKAccessTokenData.FBSDKAccessTokenDidChangeNotification

as a result of a error code 190 and sub_code 458.

My question is two part: 1) How do I get my "ok" button in the FBSDK Dialog that is automatically presented to actually DO something with the ok button? 2) How do I manually (assuming that the button above isn't working for some reason) test for the accessToken state and reauthorize the user?

This seems like there has to be a simple solution and I have spent a few days on it and cannot get ahead of this.

Thanks for any help or guidance!

like image 771
Brian Trzupek Avatar asked Nov 18 '15 03:11

Brian Trzupek


People also ask

What is Facebook_client_token?

An access token is an opaque string that identifies a user, app, or Page and can be used by the app to make graph API calls. When someone connects with an app using Facebook Login and approves the request for permissions, the app obtains an access token that provides temporary, secure access to Facebook APIs.

How do I fix an invalid access token on Facebook?

Facebook Error: Error Validating Access Token: The User Is Enrolled In A Blocking, Logged-in Checkpoint. If you've received this error, it means that your Facebook user account has failed a security checkpoint and you need to log in at https://www.facebook.com or https://m.facebook.com to correct the issue.

How do I fix an invalid access token?

There are two ways to fix the error: (RECOMMENDED) Change the application signature algorithm to RS256 instead of HS256. Change the value of your responseType parameter to token id_token (instead of the default), so that you receive an access token in the response.


1 Answers

I ran into a similar problem (it has nothing to do with Parse though). Here are my answers to the two questions you asked:

  1. It seems the FBSDK dialog's OK button doesn't work for this reason:

    Attempt to present <FBSDKContainerViewController: 0x126b222a0> on
    <FBSDKContainerViewController: 0x126a26d10> whose view is not in the window hierarchy!
    

    At least I see the above warning in the Xcode console when I try to log in to Facebook in my app (on a device connected to a Macbook) and my attempt fails. I didn't find a way to work around this particular problem. But I found a way to avoid the FBSDK dialog. See the next item.

  2. I test for the validity of the accessToken by requesting the information about the FB user. If the request fails with an error, it may mean that the accessToken is not valid. Here is a code sample:

    FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] 
        initWithGraphPath:@"me" parameters:@{@"fields": @"id, first_name, last_name"}];
    
    // The next line is important. 
    // It prevents FB SDK from handling the error automatically 
    // and allows you to handle the error yourself. 
    // In this way you avoid(!) the FBSDK dialog that says 
    // "Please login to this app again to reconnect with Facebook".
    [request setGraphErrorRecoveryDisabled:YES];
    
    [request startWithCompletionHandler:
        ^(FBSDKGraphRequestConnection *connection, id result, NSError *error){ 
    
        if (error) {
          // An error occurred. Most likely the accessToken is not valid.
          // Start the FB log-in process to obtain a valid token.
        }else{
          // Everything's all right. Go on.
        }
    }];
    
like image 188
Alexander Poleschuk Avatar answered Oct 13 '22 22:10

Alexander Poleschuk