当我尝试使用PFFacebookUtilsV4将Parse用户与Facebook链接时,它会给我以下警告:
"请再次登录此应用以重新连接您的Facebook帐户"
以下是我调用PFFacebookUtils的代码块:
/**
* Import people you are friends with on facebook from the database
*/
- (void)beginImportingFacebookFriendsForUserWithBlock:(void (^)(NSArray *results, NSError *error))cb {
if (![PFFacebookUtils isLinkedWithUser:[PFUser currentUser]]) {
NSArray *permissionsArray = @[@"user_about_me", @"user_friends", @"user_events"];
[PFFacebookUtils linkUserInBackground:[PFUser currentUser] withReadPermissions:permissionsArray block:^(BOOL succeeded, NSError *error) {
if (succeeded) {
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me"
parameters:nil];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSString *fbId = [result objectForKey:@"id"];
NSMutableDictionary *currentUserDict = [[prefs objectForKey:@"currentUser"]mutableCopy];
NSLog(@"currentUserDict:%@",currentUserDict);
[currentUserDict setObject:fbId forKey:@"fbId"];
[prefs setObject:currentUserDict forKey:@"currentUser"];
[prefs setObject:fbId forKey:@"currentFbId"];
[[PFUser currentUser] setObject:fbId forKey:@"fbId"];
[[PFUser currentUser] saveInBackground];
[self finishImportingFacebookFriendsForUserWithBlock:cb];
}
}];
}
}];
}
else {
[self finishImportingFacebookFriendsForUserWithBlock:cb];
}
}
- (void)finishImportingFacebookFriendsForUserWithBlock:(void (^)(NSArray *, NSError *))cb {
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me"
parameters:nil];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
if (!error) {
NSLog(@"result objectforkey:data %@", [result objectForKey:@"data"]);
cb([result objectForKey:@"data"], error);
}
else NSLog(@"error!:%@",error);
});
}];
}
以下是我在控制台日志中获得的内容:
2015-08-05 21:18:54.723 Huddlr[2965:391917] error!:Error Domain=com.facebook.sdk.core Code=8 "The operation couldn’t be completed. (com.facebook.sdk.core error 8.)" UserInfo=0x1741aca20 {NSRecoveryAttempter=<_FBSDKLoginRecoveryAttempter: 0x174019da0>, NSLocalizedRecoverySuggestion=Please log into this app again to reconnect your Facebook account., com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=190, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Error validating access token: The session has been invalidated because the user has changed the password., com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=400, com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=2, com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorSubcode=460, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body = {
error = {
code = 190;
"error_subcode" = 460;
message = "Error validating access token: The session has been invalidated because the user has changed the password.";
type = OAuthException;
};
};
code = 400;
}, NSLocalizedRecoveryOptions=(
OK,
Cancel
)}
错误消息是&#34;验证访问令牌时出错:会话已失效,因为用户已更改密码。&#34;即使密码没有改变。如果有人知道这里发生了什么,我们将不胜感激。
答案 0 :(得分:0)
如果您收到错误验证访问令牌 - 代码460-那么您应该注销用户并呼叫登录。