How do I force oauth authentication to be against a specific user

徘徊边缘 提交于 2019-12-11 03:59:58

问题


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.


回答1:


Add the user_id parameter to your Authorization URI.

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


来源:https://stackoverflow.com/questions/12581413/how-do-i-force-oauth-authentication-to-be-against-a-specific-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!