GIDSignIn 在提示前指定范围

问题描述 投票:0回答:2

我在 iOS 上升级到 GoogleSignIn 6.0,但找不到在登录时指定登录范围的方法。我只能看到一个名为 addScopes() 的 API,我可以在基本登录后指定范围。但这会导致两个单独的登录提示,这很奇怪。之前,我们可以简单地指定登录范围,如下所示:

  signIn = GIDSignIn.sharedInstance()
  signIn.scopes = ["https://www.googleapis.com/auth/youtube.upload"]
  signIn.signIn(...)      

我想知道新版GoogleSignIn 6.0是否有示例代码?即使是 Google 提供的示例代码也有两步登录,首先是常规登录,然后是添加范围登录。

ios google-signin gidsignin
2个回答
0
投票

目前建议执行两阶段请求:首先登录,然后请求范围权限。

GIDSignIn.sharedInstance.signIn(
    with: configuration,
    presenting: presenting,
    callback: { user, error in

        // If success
        print("Sign in successfully")

        GIDSignIn.sharedInstance.addScopes(
            ["YOUR_SCOPE"],
            presenting: presenting,
            callback: { user, error in

                // If success
                print("Scope requested successfully")

            }
        )

    }
)

参考:https://github.com/google/GoogleSignIn-iOS/issues/23#issuecomment-880233289


0
投票

我认为注意到

addScopes
方法已从
GIDSignIn
实例中删除,并移至
GIDGoogleUser
是有用的。来源:https://cocoapods.org/pods/GoogleSignIn/changelog

© www.soinside.com 2019 - 2024. All rights reserved.