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

后端 未结 2 1588
梦如初夏
梦如初夏 2020-12-11 07:15

While implementing facebook SSO, calling logout function of facebook ios sdk is not clearing user Credentials and it does not ask to login next time.

相关标签:
2条回答
  • 2020-12-11 07:46

    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

    0 讨论(0)
  • 2020-12-11 07:46

    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.

    0 讨论(0)
提交回复
热议问题