Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit affd29c

Browse files
committed
When the user is known upon signIn, remove friction.
* Do not ask for user selection again in the authorization popup * Pass the email of the known user as a hint to the signIn method
1 parent 797ecad commit affd29c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,15 @@ class GisSdkClient {
196196
/// [_initialScopes], so we can retrieve User Profile information back
197197
/// from the People API (without idToken). See [people.requestUserData].
198198
Future<GoogleSignInUserData?> signIn() async {
199+
// If we already know the user, use their `email` as a `hint`, so they don't
200+
// have to pick their user again in the Authorization popup.
201+
final GoogleSignInUserData? knownUser =
202+
utils.gisResponsesToUserData(_lastCredentialResponse);
199203
// This toggles a popup, so `signIn` *must* be called with
200204
// user activation.
201205
_tokenClient.requestAccessToken(OverridableTokenClientConfig(
206+
prompt: knownUser == null ? 'select_account' : '',
207+
hint: knownUser?.email,
202208
scope: <String>[
203209
..._initialScopes,
204210
// If the user hasn't gone through the auth process,

0 commit comments

Comments
 (0)