Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force account login for a single account user with Google's OAuth 2.0?

Sometimes when a user logins into a site with Google's OAuth 2.0 they choose the wrong account to login with. Normally this isn't a problem if the user has more than one account registered with the browser, google will automatically show the user select screen: user selection screen

But if a user has only one account and is logged in, this screen is skipped. Instead I need Google's sign in panel to always appear, so that I can be sure the user has the option to try and enter the correct account. I tried using approval_prompt = "force", but that forces the acceptance of permissions rather than simply showing the login page. Google's one user login
How can I force Google's OAuth 2.0 to always show the login screen?
(and never automatically skip it)

like image 663
Mark Rogers Avatar asked Jul 21 '15 16:07

Mark Rogers


1 Answers

Add the parameter prompt=select_account to your authorization request.

This will cause the account chooser to always be shown, even if the user is only logged in to one account. Users will be able to select from their accounts, or add a new one.

For example: 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

like image 157
William Denniss Avatar answered Sep 20 '22 10:09

William Denniss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!