I am using the following code to login on Facebook. I am using 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;
}
When I change the password in Facebook, I cannot login any more. The server is receiving
{
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
}
}
Everytime I try to refresh the token, I continue to receive the old token that the server cannot validate.
The server validates it with the following OpenGraph URI:
https://graph.facebook.com/me?access_token=ACCESS_TOKEN
How shall I fix this? Thank you