使用 Google 登录 SDK,用户可以通过 OAuth2 登录并请求一些默认范围。最好不要预先请求应用程序可能需要的每个范围,而是在以后请求额外的范围,以免用户在注册时不知所措。
Google 概述了执行此操作的过程 here .
问题是,在用户登录 Google 后,在请求额外的范围时,用户可以切换 Google 帐户并使用不同的帐户授权这些范围,然后再返回我的应用程序。
有没有一种方法,类似于调用 -[GIDSignIn signIn],明确指定我要登录的用户并且不允许更改帐户的选项?
最佳答案
我不熟悉 Google Sign in SDK。我所做的大部分工作都是我自己编写的,所以我不知道该 SDK 是如何工作的。然而,话虽如此,身份验证服务器确实支持称为 Login_hint 的东西,它应该允许您强制他们使用特定用户。
login_hint email address or sub identifier When your application knows which user it is trying to authenticate, it can provide this parameter as a hint to the Authentication Server. Passing this hint will either pre-fill the email box on the sign-in form or select the proper multi-login session, thereby simplifying the login flow.
更多信息
login_hint can be the user's email address or the sub string, which is equivalent to the user's Google ID. If you do not provide a login_hint and the user is currently logged in, the consent screen includes a request for approval to release the user’s email address to your app. (Read more at login_hint.)
如果内存服务 Google Sign in SDK 确实可以与 openId connect 一起使用,那么它应该是可能的。
关于ios - OAuth2 请求额外的范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42125357/