我使用以下代码登录Facebook。我使用的是SDK 3.5.2。
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState)state
error:(NSError *)error
{
// FBSample logic
// Any time the session is closed, we want to display the login controller (the user
// cannot use the application unless they are logged in to Facebook). When the session
// is opened successfully, hide the login controller and show the main UI.
switch (state) {
case FBSessionStateOpen: {
NSMutableDictionary *params = [[[Singleton sharedSingleton] requestParams] mutableCopy];
NSString *fbaccessToken = [session accessToken];
NSLog(@"fbaccessToken: %@", fbaccessToken);
[params setObject:fbaccessToken forKey:@"facebook_access_token"];
[params setObject:[NSString stringWithFormat:@"%d", [fbaccessToken length]] forKey:@"DEBUG_linghezza_fb_accessToken"];
[params setObject:[[FBSession activeSession] appID] forKey:@"DEBUG_appID"];
[params setObject:[[FBSession activeSession] urlSchemeSuffix] forKey:@"DEBUG_urlSchemeSuffix"];
[params setObject:[[FBSession activeSession] permissions] forKey:@"DEBUG_permessi"];
NSLog(@"%@", params);
[[[Singleton sharedSingleton] sharedClient] postPath:@"login_with_facebook.json" parameters:params
success:^(AFHTTPRequestOperation *operation, id responseObject) {
if ([[responseObject objectForKey:@"error"] isEqualToString:@"facebook_access_token not valid"]) {
NSLog(@"closeAndClearTokenInformation");
[session closeAndClearTokenInformation];
[session close];
[FBSession setActiveSession:nil];
NSLog(@"openSessionWithAllowLoginUI");
[self openSessionWithAllowLoginUI:YES];
return;
} else {...}
...
}
- (void)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSLog(@"openSessionWithAllowLoginUI:allowLoginUI");
[FBSession sessionOpenWithPermissions:[[[Singleton sharedSingleton] initPrefs] objectForKey:@"facebook_permissions"] completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
[self sessionStateChanged:session state:status error:error];
}];
return;
}
当我在Facebook更改密码时,我无法再登录了。服务器正在接收
{
error: {
message: "Error validating access token: The session has been invalidated because the user has changed the password.",
type: "OAuthException",
code: 190,
error_subcode: 460
}
}
每当我尝试刷新令牌时,我都会继续收到服务器无法验证的旧令牌。
服务器使用以下OpenGraph URI验证它:
https://graph.facebook.com/me?access_token=ACCESS_TOKEN
我该如何解决这个问题?谢谢