谷歌多次登录使用GIDSignin [英] Google multiple login using GIDSignin

查看:411
本文介绍了谷歌多次登录使用GIDSignin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 GIDSignIn 通过以下代码对单个帐户进行身份验证。

I can do authentication for single account using GIDSignIn by below code.

    GIDSignIn *googleSignIn = [GIDSignIn sharedInstance];
    googleSignIn.delegate = self;
    googleSignIn.uiDelegate = self;
    googleSignIn.clientID = (NSString*)cGmailAppClientId;
    googleSignIn.scopes = [self getGmailAuthenticationScopes];;
    [googleSignIn signIn];

GIDSignIn 是共享实例。这是一个只有一个帐户。如何添加多个帐户? 可同时访问多个帐户(Ex获取访问令牌)。

But GIDSignIn is shared instance. It is for an only one account. How can I add multiple accounts? Multiple accounts should accessible concurrently (Ex getting access token).

相关问题没有给出正确的想法。

Related SO question doesn't give correct idea.

推荐答案

我认为 GIDSignIn 支持多个帐户。理论上,您可以实例化 sharedInstance 以外的实例,但一次只有一个授权将持久保存到iOS钥匙串。 (该库需要多个密钥才能保存多个授权,但如果您实例化多个实例,它怎么知道冷启动后哪个是哪个?)

I don't think GIDSignIn supports multiple accounts. While in theory you could instantiate instances other than the sharedInstance, only one authorization will be persisted to the iOS keychain at a time. (The library would need multiple keys to save multiple authorizations, but if you instantiated multiple instances, how could it know which was which after a cold launch?)

幸运的是,有 Google的 GTMAppAuth 实现相同目的的替代库。使用它比使用 GIDSignIn 要复杂一些,但工作方式基本相同。关键的区别在于:1)您可以一次创建多个授权,以及2)您可以使用您选择的密钥将它们保存到iOS钥匙串。如果您对访问Gmail有兴趣,请从热门的MailCore2库中这些步骤可能会有帮助。

Fortunately, there's Google's GTMAppAuth, an alternative library that fulfills the same purpose. It's a bit more complicated to use than GIDSignIn, but works in generally the same fashion. The key differentiators are that 1) you can create multiple authorizations at a time, and 2) you can persist them to the iOS keychain with keys of your choosing. If you're interested specifically in accessing Gmail, then these steps from the popular MailCore2 library may be helpful.

听起来来自这个帖子,这些图书馆得到了公司内不同团队的支持,但我怀疑它们会在融合之前有一段时间,如果有的话。

It sounds from this thread like the libraries are supported by different teams within the company, but I suspect it will be a while before they converge, if ever.

这篇关于谷歌多次登录使用GIDSignin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆