Checking If User has Modified Facebook Permission For App
I am using Facebook
to create a new user or log in to Parse .
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.
IE: The user goes to Facebook App settings and deleted the App from the list.
ps: Please help vote up this question as It's really hard to find the solution. Thank you!!
Thank you
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
I think you can find the answer you're looking for in here:
https://developers.facebook.com/docs/facebook-login/ios/permissions
You could either:
1) Check for errors yourself:
let token = FBSDKAccessToken.currentAccessToken()
if token.hasGranted("publish_actions") //Or whatever other permission you're checking
2) Perform some action anyway and check the error:
if error.userInfo[FBSDKGraphRequestErrorGraphErrorCode] == 200
{
//Handle missing permissions here
}
I'm guessing that the currentAccessToken
would be cached information from the last time they logged in, so the second option might be the way to go.
You could configure a Deauthorize Callback URL for your app. Therefore, you'll need to create a backend service which can handle the incoming HTTP POST requests from Facebook once a user deauthorizes your app.
See
for details.
链接地址: http://www.djcxy.com/p/27484.html