简体   繁体   中英

Calling logout function of facebook ios sdk is not clearing user Credentials

在实施facebook SSO时,调用facebook ios sdk的注销功能不会清除用户凭据,也不会要求下次登录。

I Used Graph Api.....

- (IBAction)loginButtonPressed:(id)sender {

    NSString *client_id = @"dsfgdgfgfgdfgvdfg";

    //alloc and initalize our FbGraph instance
    self.fbGraph = [[FbGraph alloc] initWithFbClientID:client_id];

    //begin the authentication process.....
    [fbGraph authenticateUserWithCallbackObject:self andSelector:@selector(fbGraphCallback:) 
                         andExtendedPermissions:@"user_photos,user_videos,publish_stream,offline_access,user_checkins,friends_checkins"];
}


- (void)logOutButtonPressed {

    NSLog(@"logout");

    fbGraph.accessToken = nil;
    NSHTTPCookie *cookie;
    NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    for (cookie in [storage cookies])
    {
        NSString* domainName = [cookie domain];
        NSRange domainRange = [domainName rangeOfString:@"facebook"];
        if(domainRange.length > 0)
        {
            [storage deleteCookie:cookie];
        }
    }

    [self loginButtonPressed:nil];
}

And This code is WORKING FINE..TRY THIS

I've experienced the same, however I think it's not a bug, confusing though.

Facebook places a cookie in the mobile safari which refers to a valid session or maybe an access token. If you logout with the Facebook lib it clears the access token and all cookies of the webview used not in mobile safari. Actually you can't do that by code. Now if you come back and mobile safari opens up, there is still a valid session and you are logged in again without entering credentials.

You may file a bug to ask if Facebook can invalidate the access token server side.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM