ios - OAuth2 请求额外的范围

标签 ios google-api google-signin google-oauth

使用 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/

相关文章:

ios - 具有 iOS 年度 View 的日历控件

python - 在本地主机上使用 Google OAuth

javascript - 如何在 JS 异步回调函数中返回一个值 - gapi

android - 在 Android Studio 中放置 credentials.json 的位置

android - 谷歌登录无法在 Play 商店中使用生产 apk。(在 Play 商店中发布 apk)

php - 尝试在 Xcode NSCocoaErrorDomain Code=3840 中解析 JSON

iphone - UTF8 iPhone 无法读取阿姆哈拉语字母

ios - 快速更改 UIEdgeInsets 的颜色

php - 如何以编程方式使用 Google Analytics API 函数获取指标和维度列表?

google-api - 在弹出窗口中打开 Google SignIn 用户身份验证,需要使用 OAuth 2.0 在同一个 Tab 本身中打开