如果用户在浏览器中注册了多个帐户,则有时当用户使用Google登录网站时出现问题,Google会自动显示用户选择屏幕:
但是,如果用户只有一个帐户并且已登录,则会跳过此屏幕 . 相反,我需要Google的登录面板始终显示,以便我可以确定用户可以选择尝试输入正确的帐户 . 我尝试使用 approval_prompt = "force"
,但这会强制接受权限而不是简单地显示登录页面 .
How can I force Google's OAuth 2.0 to always show the login screen?
(并且永远不会自动跳过它)
1 回答
将参数
prompt=select_account
添加到您的授权请求中 .这将导致始终显示帐户选择器,即使用户仅登录到一个帐户也是如此 . 用户可以从他们的帐户中进行选择,也可以添加新帐户 .
例如:https://accounts.google.com/o/oauth2/auth?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=profile+email&access_type=offline&prompt=select_account