我正在遵循 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/