如何强制oauth身份验证针对特定用户 [英] How do I force oauth authentication to be against a specific user

查看:213
本文介绍了如何强制oauth身份验证针对特定用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照 https://developers.google.com中所述的方式执行客户端身份验证/ accounts / docs / OAuth2UserAgent



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



当用户注册我的服务,他们这样做与特定的电子邮件地址(和谷歌身份证)。



如何限定oauth对话,使其始终只使用指定的用户?



https://developers.google.com/drive/about-auth 上我可以看到...

 注意:如果您想使用user_id参数从
中选择当前用户潜在地)多个登录帐户,
也添加https://www.googleapis.com/auth/userinfo.email。

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

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

  gapi.auth.authorize({...,user_id:'ali@gmail.com'}, handleAuthResult); 


I'm following the client side authentication as described at https://developers.google.com/accounts/docs/OAuth2UserAgent

I am routinely signed on to multiple Google accounts. Normally, the flow will prompt me to choose which account I want to authenticate with. However there are sometimes instances where it assumes the first account I signed in with, which is not the account I wish to use.

When users register with my service, they do so with a specific email address (and google id).

How do I qualify the oauth dialogue such that it will always take place using only the specified user?

On https://developers.google.com/drive/about-auth I can see a comment...

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.

The implies that there is a user_id parameter I can include in the oauth call, but I can't see it documented anywhere, and there is nowhere in the Javascript API where I can inject a user_id.

解决方案

Add the user_id parameter to your Authorization URI.

 gapi.auth.authorize({..., user_id: 'ali@gmail.com'}, handleAuthResult);

这篇关于如何强制oauth身份验证针对特定用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆