2

我正在遵循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 中没有可以注入 user_id 的地方。

4

1 回答 1

3

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

 gapi.auth.authorize({..., user_id: 'ali@gmail.com'}, handleAuthResult);
于 2012-09-25T14:56:08.657 回答