2013-03-15 51 views
2

我從LinkedIn註銷時遇到問題。我想要用戶在執行註銷方法後,看到LinkedIn以用戶名和密碼的形式演唱。GTMOAuthViewControllerTouch和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]; 

Singout方法:

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

但是,下一次我在唱,OAuth的失誤步驟有我需要輸入LinkedIn憑據。

只有當應用程序被刪除並重新安裝時,該應用程序纔會請求登錄名和密碼。

回答

1

儘管存在[GTMOAuth clearBrowserCookies]方法。 我手動刪除所有餅乾與 「LinkedIn」 域在singout方法

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

for (NSHTTPCookie *cookie in cookies) { 
    if ([cookie.domain rangeOfString:@"linkedin"].location != NSNotFound) { 
     [cookieStorage deleteCookie:cookie]; 
    } 
} 
1

在夫特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) 
      } 
     } 
    }