2

我在从 LinkedIn 注销时遇到问题。我希望用户在执行注销方法后看到带有用户名和密码的 LinkedIn 唱歌。

唱入法:

NSURL *authorizeTokenURL = [NSURL URLWithString:@"https://www.linkedin.com/uas/oauth/authenticate"];
NSURL *accessTokenURL = [NSURL URLWithString:@"https://api.linkedin.com/uas/oauth/accessToken"];

GTMOAuthViewControllerTouch *authViewControllerTouch = [[GTMOAuthViewControllerTouch alloc] initWithScope:nil language:nil requestTokenURL:requestTokenURL authorizeTokenURL:authorizeTokenURL accessTokenURL:accessTokenURL authentication:authentication appServiceName:@"AppServiceName" delegate:self finishedSelector:@selector(linkedInAuthSelector:finishedWithAuth:error:)];

[authViewControllerTouch setBrowserCookiesURL:[NSURL URLWithString:@"https://api.linkedin.com/"]];

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:authViewControllerTouch];
[self presentViewController:navigationController animated:YES completion:nil];

出线方法:

- (void) logout{
    [GTMOAuthViewControllerTouch removeParamsFromKeychainForName:@"AppServiceName"];
}

但是,下次我唱歌时,OAuth 错过了我需要输入 LinkedIn 凭据的步骤。

该应用程序仅在删除并重新安装时才请求登录名和密码。

4

2 回答 2

1

尽管存在 [GTMOAuth clearBrowserCookies] 方法。我在 singout 方法中手动删除域中带有“linkedin”的所有 cookie

NSHTTPCookieStorage *cookieStorage;
cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSArray *cookies =  [cookieStorage cookies];

for (NSHTTPCookie *cookie in cookies) {
    if ([cookie.domain rangeOfString:@"linkedin"].location != NSNotFound) {
        [cookieStorage deleteCookie:cookie];
    }
}
于 2013-03-15T21:23:30.163 回答
1

在 Swift 3 中,使用以下代码:

            // LinkedIn Cookie Purge
    let cookieStorage: HTTPCookieStorage = HTTPCookieStorage.shared
    if let cookies = cookieStorage.cookies {
        for cookie in cookies {
            if cookie.domain.contains("linkedin") {
                cookieStorage.deleteCookie(cookie)
            }
        }
    }
于 2017-06-28T00:14:26.127 回答