首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >谷歌OAuth2记忆用户

谷歌OAuth2记忆用户
EN

Stack Overflow用户
提问于 2013-07-15 02:18:41
回答 1查看 275关注 0票数 1

我一直在尝试在他们的Objective-C库中使用谷歌提供的OAuth2 api。

无论如何,我在理解如何让应用程序记住谁登录时遇到了麻烦。我已经使用下面的代码成功地完成了身份验证。

我调用下面的方法来呈现来自谷歌的OAuth视图控制器,用户登录,然后我就通过了身份验证。然而,每次我重新启动应用程序时,它都会再次运行登录屏幕,就好像我没有通过身份验证一样。据我所知,我需要有某种类型的密钥链/令牌记忆,以便它能够识别最近登录的用户。

但是怎么做呢?我不能通过一些可用的文档来解决这个问题。

代码语言:javascript
复制
-(void)authenticateUserFromViewController:(UIViewController *)viewController
{
    GTMOAuth2ViewControllerTouch *authViewController = [[GTMOAuth2ViewControllerTouch alloc] initWithScope:kGTLAuthScopeYouTube
                                                                clientID:kClientID
                                                            clientSecret:kClientSecret
                                                        keychainItemName:kKeychainItemName
                                                                delegate:self
                                                        finishedSelector:@selector(viewController:finishedWithAuth:error:)];

    [viewController.navigationController pushViewController:authViewController animated:YES];
}

-(void)viewController:(GTMOAuth2ViewControllerTouch *)viewController finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error
{
    if (error != nil)
    {
        // Authentication failed
        NSLog(@"Failed to authorise");
    }
    else
    {
        // Authentication succeeded
        NSLog(@"Authorised");
    }
}
EN

回答 1

Stack Overflow用户

发布于 2013-07-16 02:33:19

我不熟悉Objective-C库,但也许this part of the Google Reference会很有用。它解释了如何使用身份验证令牌,以及如何在用户重新启动应用程序时处理密钥链。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17642258

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档