I am developing the application which allow user to login via Facebook (using Facebook SDK for it). The error appears when a user has already logged in Facebook in iPhone settings. If not - all work correctly.
NSArray *permissions = [[NSArray alloc] initWithObjects:@"email", nil];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
[self fbSessionStateChanged:session state:state error:error];
}];
I've already tried to set permissions as nil array - nothing changed.
Error Domain=com.facebook.sdk Code=2 "The operation couldn’t be completed.
(com.facebook.sdk error 2.)" UserInfo=0x1552c6c0
{com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:SystemLoginDisallowedWithoutError,
com.facebook.sdk:ErrorSessionKey=<FBSession: 0xabe8100, state: FBSessionStateClosedLoginFailed,
loginHandler: 0x0, appID: APPIDHERE, urlSchemeSuffix: ,
tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x14b8f3d0>,
expirationDate: (null), refreshDate: (null),
attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>}
Sometimes the error with Code 7 is appears too. I have read almost all topics related to this error.
My steps were:
[FBSession openActiveSessionWithReadPermissions:permissions
to [FBSession openActiveSessionWithPermissions:permissions
- it works. But it is deprecated. Yes, after you see this error, if you go to Settings, you will see that the setting for this app is turned "OFF". But the problem in this case is that the user was never prompted to allow access -- i.e. the setting was turned to OFF automatically on first time access. If the user was asked, then of course that is understandable, but this is not the case (it's as if the SDK silently and automatically pressed Don't Allow for the user). That's why this is a problem.
Before you read any further, I want to note that once the setting is set, you cannot simply repeat the process to test it, because once the setting is set, it will never ask the user (even deleting and reinstalling the app does not help). To test this issue, you need to reset the permissions by going to Settings -> General -> Reset -> Reset Location & Privacy, before you can try to replicate this again.
From testing, I've discovered that if you have offline_access in the permissions you are requesting for the first time, then it will give this login error (and not prompt the user and set the permission to OFF). The SDK does not check and tell you that this permission is not allowed; it just fails to login.
This is how I got mine to work- Pass it an empty permissions array.
NSArray *permissionsArray = @[];
However, make sure you have the permissions you want set up in my facebook app page. I only needed the default one so I was okay.
I have a feeling that facebook changed it's server side code. My app was working fine, and then my FB login broke.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With