Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google OAuth Login: Avoid asking the User to choose which account to use

I am relying on Google OAuth to authorize a user for a site I'm building. At the time I'm requesting permission, I already know which Google Account he wants to use (I'm using Google OAuth as a second level auth). However if the User is logged in to several Google Accounts at once, Google redirects the user to a SelectSession interface.

When the user is directed to https://accounts.google.com/o/oauth2/auth?... he ends on https://www.google.com/a/SelectSession. This is unnecessary, because I already know which session he wants to use.

Does anyone know a way to automatically select a specific account, so that the user does not need to manually select the session at https://www.google.com/a/SelectSession?

like image 843
lucasvo Avatar asked Sep 20 '12 05:09

lucasvo


1 Answers

If you already know the user's email address you can add the query parameter user_id= as a hint. If the user is logged in as that account, it'll skip the account selection and go straight to the approval.

It doesn't guarantee the user will actually authorize with that account. Its just a hint and there are still opportunities for them to switch to a different account. If you need to know for sure which account they selected, you'd need to verify that afterwards (e.g. call the userinfo endpoint.)

like image 116
Steve Bazyl Avatar answered Oct 19 '22 00:10

Steve Bazyl