Вопрос

I've implemented Google OAuth 2.0 login on a site that I'm working on. It works fine, except in situations when the user is logged with two or more different accounts on the same browser. It's asking him to choose which one he want's to use. But it's asking the user every time to choose the account. Is there a way to remember this, so the user can choose the account only the first time and later automatically to log him with that account?

You can put hd=domain.com parameter in the request to Google, but that only helps if the two logged accounts are from different domains and it can than log the user in with @domain.com account.

I read somewhere that you can send user_id account as a parameter to Google (I guess that would be the email address), but in this case I don't know the users email address before he logs in.

I think this behavior is the same if you use OpenID.

I'm using Google's PHP OAuth library.

Thanks, Andrej

Это было полезно?

Решение

Google should have a cookie set that enables OAuth applications to tell what account to currently use.

Другие советы

If you know the email address you want to log in with, you can use the login_hint parameter and they won't see the account chooser. See https://developers.google.com/accounts/docs/OAuth2Login#sendauthrequest

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top