Skip to content

Commit 86e9d00

Browse files
Review feedback
1 parent 012a6d7 commit 86e9d00

File tree

8 files changed

+75
-16
lines changed

8 files changed

+75
-16
lines changed

packages/google_sign_in/google_sign_in/lib/google_sign_in.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ class GoogleSignInAccount implements GoogleIdentity {
5454
/// Returns authentication tokens for this account.
5555
///
5656
/// This returns the authentication information that was returned at the time
57-
/// of the initial authentication. Clients are strongly encouraged to use this
58-
/// information immediately after authentication, as tokens are subject to
59-
/// expiration, and obtaining new tokens requires re-authenticating.
57+
/// of the initial authentication.
58+
///
59+
/// Clients are strongly encouraged to use this information immediately after
60+
/// authentication, as tokens are subject to expiration, and obtaining new
61+
/// tokens requires re-authenticating.
6062
GoogleSignInAuthentication get authentication {
6163
return GoogleSignInAuthentication(idToken: _authenticationTokens.idToken);
6264
}

packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class GoogleSignInAndroid extends GoogleSignInPlatform {
6363
: _authenticationResultFromPlatformCredential(credential);
6464
}
6565

66+
@override
67+
bool supportsAuthenticate() => true;
68+
6669
@override
6770
Future<AuthenticationResults> authenticate(
6871
AuthenticateParameters params) async {
@@ -100,6 +103,9 @@ class GoogleSignInAndroid extends GoogleSignInPlatform {
100103
await signOut(const SignOutParams());
101104
}
102105

106+
@override
107+
bool authorizationRequiresUserInteraction() => false;
108+
103109
@override
104110
Future<ClientAuthorizationTokenData?> clientAuthorizationTokensForScopes(
105111
ClientAuthorizationTokensForScopesParameters params) async {

packages/google_sign_in/google_sign_in_android/test/google_sign_in_android_test.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ void main() {
5050
expect(GoogleSignInPlatform.instance, isA<GoogleSignInAndroid>());
5151
});
5252

53+
group('support queries', () {
54+
test('reports support for authenticate', () {
55+
expect(googleSignIn.supportsAuthenticate(), true);
56+
});
57+
58+
test('reports no requirement for user interaction to authorize', () {
59+
expect(googleSignIn.authorizationRequiresUserInteraction(), false);
60+
});
61+
});
62+
5363
group('attemptLightweightAuthentication', () {
5464
test('passes explicit server client ID', () async {
5565
const String serverClientId = 'aServerClient';

packages/google_sign_in/google_sign_in_ios/lib/google_sign_in_ios.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class GoogleSignInIOS extends GoogleSignInPlatform {
5959
return _authenticationResultsFromSignInSuccess(success);
6060
}
6161

62+
@override
63+
bool supportsAuthenticate() => true;
64+
6265
@override
6366
Future<AuthenticationResults> authenticate(
6467
AuthenticateParameters params) async {
@@ -99,6 +102,9 @@ class GoogleSignInIOS extends GoogleSignInPlatform {
99102
await signOut(const SignOutParams());
100103
}
101104

105+
@override
106+
bool authorizationRequiresUserInteraction() => false;
107+
102108
@override
103109
Future<ClientAuthorizationTokenData?> clientAuthorizationTokensForScopes(
104110
ClientAuthorizationTokensForScopesParameters params) async {

packages/google_sign_in/google_sign_in_ios/test/google_sign_in_ios_test.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ void main() {
3535
expect(GoogleSignInPlatform.instance, isA<GoogleSignInIOS>());
3636
});
3737

38+
group('support queries', () {
39+
test('reports support for authenticate', () {
40+
expect(googleSignIn.supportsAuthenticate(), true);
41+
});
42+
43+
test('reports no requirement for user interaction to authorize', () {
44+
expect(googleSignIn.authorizationRequiresUserInteraction(), false);
45+
});
46+
});
47+
3848
group('init', () {
3949
test('passes expected values', () async {
4050
const String clientId = 'aClient';

packages/google_sign_in/google_sign_in_platform_interface/lib/google_sign_in_platform_interface.dart

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,27 @@ abstract class GoogleSignInPlatform extends PlatformInterface {
5959
Future<AuthenticationResults?>? attemptLightweightAuthentication(
6060
AttemptLightweightAuthenticationParameters params);
6161

62-
/// Signs in with explicit user intent.
63-
///
64-
/// This is intended to support the use case where the user has expressed
65-
/// an explicit intent to sign in.
66-
Future<AuthenticationResults> authenticate(AuthenticateParameters params);
67-
6862
/// Returns true if the platform implementation supports the [authenticate]
6963
/// method.
7064
///
7165
/// The default is true, but platforms that cannot support [authenticate] can
7266
/// override this to return false, throw [UnsupportedError] from
7367
/// [authenticate], and provide a different, platform-specific authentication
7468
/// flow.
75-
bool supportsAuthenticate() => true;
69+
bool supportsAuthenticate();
70+
71+
/// Signs in with explicit user intent.
72+
///
73+
/// This is intended to support the use case where the user has expressed
74+
/// an explicit intent to sign in.
75+
Future<AuthenticationResults> authenticate(AuthenticateParameters params);
7676

7777
/// Whether or not authorization calls that could show UI must be called from
7878
/// a user interaction, such as a button press, on the current platform.
7979
///
80-
/// The default is true, but platforms that can fail to show UI without an
81-
/// active user interaction should override this to return true. For instance,
82-
/// this should return true for a web implementations that uses popups.
83-
bool authorizationRequiresUserInteraction() => false;
80+
/// Platforms that can fail to show UI without an active user interaction,
81+
/// such as a web implementations that uses popups, should return false.
82+
bool authorizationRequiresUserInteraction();
8483

8584
/// Returns the tokens used to authenticate other API calls from a client.
8685
///
@@ -99,8 +98,8 @@ abstract class GoogleSignInPlatform extends PlatformInterface {
9998
/// Signs out previously signed in accounts.
10099
Future<void> signOut(SignOutParams params);
101100

102-
/// Revokes all of the scopes that all signed in users granted, and then them
103-
/// out.
101+
/// Revokes all of the scopes that all signed in users granted, and then signs
102+
/// them out.
104103
Future<void> disconnect(DisconnectParams params);
105104

106105
/// Returns a stream of authentication events.
@@ -136,11 +135,21 @@ class _PlaceholderImplementation extends GoogleSignInPlatform {
136135
throw UnimplementedError();
137136
}
138137

138+
@override
139+
bool supportsAuthenticate() {
140+
throw UnimplementedError();
141+
}
142+
139143
@override
140144
Future<AuthenticationResults> authenticate(AuthenticateParameters params) {
141145
throw UnimplementedError();
142146
}
143147

148+
@override
149+
bool authorizationRequiresUserInteraction() {
150+
throw UnimplementedError();
151+
}
152+
144153
@override
145154
Future<ClientAuthorizationTokenData?> clientAuthorizationTokensForScopes(
146155
ClientAuthorizationTokensForScopesParameters params) {

packages/google_sign_in/google_sign_in_platform_interface/test/google_sign_in_platform_interface_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,17 @@ class ExtendsGoogleSignInPlatform extends GoogleSignInPlatform {
112112
return null;
113113
}
114114

115+
@override
116+
bool supportsAuthenticate() => false;
117+
115118
@override
116119
Future<AuthenticationResults> authenticate(AuthenticateParameters params) {
117120
throw UnimplementedError();
118121
}
119122

123+
@override
124+
bool authorizationRequiresUserInteraction() => false;
125+
120126
@override
121127
Future<ClientAuthorizationTokenData?> clientAuthorizationTokensForScopes(
122128
ClientAuthorizationTokensForScopesParameters params) async {

packages/google_sign_in/google_sign_in_web/example/integration_test/web_only_test.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,14 @@ class NonWebImplementation extends GoogleSignInPlatform {
101101
Future<void> signOut(SignOutParams params) {
102102
throw UnimplementedError();
103103
}
104+
105+
@override
106+
bool authorizationRequiresUserInteraction() {
107+
throw UnimplementedError();
108+
}
109+
110+
@override
111+
bool supportsAuthenticate() {
112+
throw UnimplementedError();
113+
}
104114
}

0 commit comments

Comments
 (0)