oauth-2.0 - 如何强制针对特定用户进行 oauth 身份验证

标签 oauth-2.0 google-drive-api google-authentication

我正在遵循 https://developers.google.com/accounts/docs/OAuth2UserAgent 中所述的客户端身份验证

我经常登录多个 Google 帐户。通常,流程会提示我选择要使用哪个帐户进行身份验证。然而,有时它会假定我登录的第一个帐户,这不是我希望使用的帐户。

当用户注册我的服务时,他们会使用特定的电子邮件地址(和 Google ID)进行注册。

如何限定 oauth 对话,使其始终仅使用指定用户进行?

关于https://developers.google.com/drive/about-auth我可以看到评论...

Note: If you want to use the user_id parameter to select the current user from
 (potentially) multiple logged-in accounts,
 also add https://www.googleapis.com/auth/userinfo.email.

这意味着我可以在 oauth 调用中包含一个 user_id 参数,但我在任何地方都看不到它的记录,并且 Javascript API 中没有任何地方可以注入(inject) user_id。

最佳答案

将 user_id 参数添加到您的授权 URI。

 gapi.auth.authorize({..., user_id: '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a5c4c9cce5c2c8c4ccc98bc6cac8" rel="noreferrer noopener nofollow">[email protected]</a>'}, handleAuthResult);

关于oauth-2.0 - 如何强制针对特定用户进行 oauth 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12581413/

相关文章:

Javascript - 关于如何获取用户 ID 的 Firebase 函数

android - Android 应用程序上的 Firebase 上的 Facebook/Google 注册

java - Spring安全OAuth 2

android - Twitter 是否支持 OAuth 2.0?

oauth-2.0 - 尝试通过 API key 授权访问 Google BigQuery

google-drive-api - 如何在Drive API v3中获取permissionId?

python - 为什么 Google API V3 不返回 child ?

google-drive-api - 如何将 folium map 直接保存到谷歌驱动器

asp.net-mvc - 谷歌 aspnet mvc5 上的 AuthenticationManager.GetExternalLoginInfoAsync() 返回 null

security - 我应该重用OAuth 2.0访问 token 吗?