@@ -13,10 +13,19 @@ class GoogleProvider extends OAuthProvider {
13
13
final providerId = 'google.com' ;
14
14
15
15
/// The Google client ID.
16
- /// Will be ignored on Android since it's not needed.
16
+ /// Primarily required for desktop platforms.
17
+ /// Ignored on Android and iOS (if `iOSPreferPlist` is true).
17
18
final String clientId;
18
19
20
+ /// When true, the Google Sign In plugin will use the GoogleService-Info.plist
21
+ /// for configuration instead of the `clientId` parameter.
22
+ final bool iOSPreferPlist;
23
+
24
+ /// The redirect URL to use for the Google Sign In plugin.
25
+ /// Required on desktop platforms.
19
26
final String ? redirectUri;
27
+
28
+ /// The list of requested authroization scopes requested when signing in.
20
29
final List <String >? scopes;
21
30
22
31
late GoogleSignIn provider;
@@ -37,25 +46,31 @@ class GoogleProvider extends OAuthProvider {
37
46
required this .clientId,
38
47
this .redirectUri,
39
48
this .scopes,
49
+ this .iOSPreferPlist = false ,
40
50
}) {
41
51
firebaseAuthProvider.setCustomParameters (const {
42
52
'prompt' : 'select_account' ,
43
53
});
44
54
45
- // `clientId` is not supported on Android and is misinterpreted as a
46
- // `serverClientId`. This is a workaround to avoid the error.
47
- if (defaultTargetPlatform == TargetPlatform .android) {
48
- provider = GoogleSignIn (
49
- scopes: scopes ?? [],
50
- );
55
+ if (_ignoreClientId ()) {
56
+ provider = GoogleSignIn (scopes: scopes ?? []);
51
57
} else {
52
58
provider = GoogleSignIn (
53
- scopes: scopes ?? [],
54
59
clientId: clientId,
60
+ scopes: scopes ?? [],
55
61
);
56
62
}
57
63
}
58
64
65
+ bool _ignoreClientId () {
66
+ if (defaultTargetPlatform == TargetPlatform .android) return true ;
67
+ if (defaultTargetPlatform == TargetPlatform .iOS && iOSPreferPlist) {
68
+ return true ;
69
+ }
70
+
71
+ return false ;
72
+ }
73
+
59
74
@override
60
75
void mobileSignIn (AuthAction action) async {
61
76
provider.signIn ().then ((user) {
0 commit comments