Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking If User has Modified Facebook Permission For App

I am using Facebook to create a new user or log in to Parse.

  1. User logs in to app using Facebook login
  2. User is prompt to accept the permissions.
  3. User accept all permissions that the app requested.

4. User removed permission for app (delete app from Facebook)

I am wondering what is the way for us to check if the user has change the authorization status of the app in Facebook.

How do I check it? How do we know that it is no longer connected?

FBSDKAccessToken.currentAccessToken(); does not do the job, as it can only check if the token exists or not in the device.

I.E.: The user goes to Facebook App settings and deleted the App from the list.

p.s.: Please help vote up this question as It's really hard to find the solution. Thank you!!

Thank you

like image 873
JayVDiyk Avatar asked Jul 12 '15 16:07

JayVDiyk


1 Answers

Handling an Invalidated Session

We cannot know if the cached Facebook session is valid until we attempt to make a request to the API. A session can become invalidated if a user changes their password or revokes the application's privileges. When this happens, the user needs to be logged out. We can identify an invalid session error within a FBSDKGraphRequest completion handler and automatically log the user out.

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil];
    [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
        if (!error) {
            // handle successful response
        } else if ([[error userInfo][@"error"][@"type"] isEqualToString: @"OAuthException"]) { // Since the request failed, we can check if it was due to an invalid session
            NSLog(@"The facebook session was invalidated");
            [PFFacebookUtils unlinkUserInBackground:[PFUser currentUser]];
        } else {
            NSLog(@"Some other error: %@", error);
        }
    }];

Source: Integrate Login with Facebook

like image 74
Eddy Liu Avatar answered Sep 23 '22 09:09

Eddy Liu