ios facebook sdk 4.0 login error code 304

后端 未结 14 1898
死守一世寂寞
死守一世寂寞 2020-12-08 01:36

I\'ve just updated facebook sdk v4.0

and according the tutorial of Using Custom Login UIs

-(IBAction)facebookLoginClick:(id)sender {

FBSDKLoginManag         


        
14条回答
  •  感情败类
    2020-12-08 02:07

    Actually, the reason is very simple, you can try following step to reappear this error code easily.

    The "Facebook login fail" may have two reasons:

    1. you get the user info from facebook fail.
    2. you get the user info from facebook success,but upload to your own server fail.

    The code in FBSDKLoginManager.m is:

    - (void)validateReauthentication:(FBSDKAccessToken *)currentToken withResult:(FBSDKLoginManagerLoginResult *)loginResult
    {
      FBSDKGraphRequest *requestMe = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me"
                                                                       parameters:nil
                                                                      tokenString:loginResult.token.tokenString
                                                                       HTTPMethod:nil
                                                                            flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery];
      [requestMe startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    NSString *actualID = result[@"id"];
      if ([currentToken.userID isEqualToString:actualID]) {
        [FBSDKAccessToken setCurrentAccessToken:loginResult.token];
        [self invokeHandler:loginResult error:nil];
      } else {
        NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
        [FBSDKInternalUtility dictionary:userInfo setObject:error forKey:NSUnderlyingErrorKey];
        NSError *resultError = [NSError errorWithDomain:FBSDKLoginErrorDomain
                                                 code:FBSDKLoginUserMismatchErrorCode
                                             userInfo:userInfo];
       [self invokeHandler:nil error:resultError];
      }
    }];
    }
    

    when currentToken.userID is not equal actualID, the FBSDKLoginUserMismatchErrorCode will throw.

    Now, this issue will reappear when user A login facebook fail,but you do not have [FacebookSDKManager logOut] after the fail, the app will cache the accessToken for the user A , and then user A change facebook account to user B, when user B login facebook again,it will reappear this issue.

提交回复
热议问题