Google Sign-In for Websites Feature Request - Ability to check if user is signed in

30 views
Skip to first unread message

Marc Mouallem

unread,
Nov 16, 2015, 1:45:04 AM11/16/15
to Google Identity Toolkit
Currently the apparent way to do this is using the `GoogleAuth.signIn(options)` method. However the issue is that the promise is only returned if the sign in is successful. Nothing is returned otherwise.

Per the documentation GoogleAuth.signIn(options) signs in the user using the passed options.

If providing the option "prompt" the Google docs state behavior is specified by the OpenID Connect Request Parameters. The relevant section being as follows.

none: The Authorization Server MUST NOT display any authentication or    consent user interface pages. An error is returned if an End-User is not already authenticated or the Client does not have pre-configured consent for the requested Claims or does not fulfill other conditions for processing the request. The error code will typically be login_required, interaction_required. This can be used as a method to check for existing authentication and/or consent.

However the signIn() promise is only fulfilled "when the user successfully authenticates and grants the requested scopes". Meaning there is no way of using "prompt: none" to check if a user is already authenticated. In fact, there is no way of doing this at all.

Demo: http://plnkr.co/edit/3Y0USSzziWGmY4fG62Db?p=preview

The behavior is the same with the onSuccess and onFailure callbacks on the rendered button.

My Current workaround is to render the button regardless of the sign-in state and init my page on successful sign-in automatically or if no successful promise is returned wait till the user signs in. The problem here is that even if the user is already signed-in the button has to appear briefly. This is sloppy looking.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages