【问题标题】:GTMOAuthViewControllerTouch and LinkedIn signoutGTMOAuthViewControllerTouch 和 LinkedIn 注销
【发布时间】:2013-03-04 16:35:51
【问题描述】:

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

SingIn 方法:

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 凭据的步骤。

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

【问题讨论】:

    标签: ios objective-c oauth linkedin


    【解决方案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];
        }
    }
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2012-12-05
        • 2023-01-08
        • 1970-01-01
        • 2012-08-19
        • 1970-01-01
        • 2011-08-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多