调用 facebook ios sdk 的注销功能不会清除用户凭据

发布于 2024-11-08 03:32:43 字数 67 浏览 2 评论 0原文

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风柔一江水 2024-11-15 03:32:43

我使用了 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];
}

并且这段代码工作正常...尝试一下

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

水水月牙 2024-11-15 03:32:43

我也经历过同样的事情,但我认为这不是一个错误,尽管令人困惑。

Facebook 在移动 safari 中放置了一个 cookie,它指的是有效会话或访问令牌。如果您使用 Facebook lib 注销,它会清除访问令牌以及移动 safari 中未使用的 webview 的所有 cookie。实际上你不能通过代码做到这一点。现在,如果您回来并打开 mobile safari,则仍然存在有效会话,并且您无需输入凭据即可再次登录。

您可以提交一个错误来询问 Facebook 是否可以使访问令牌服务器端无效。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文