Skip to content

Commit 162597f

Browse files
authored
fix(ui_auth, ui_oauth_google): allow GoogleService-Info.plist based configuration (#10360)
1 parent 538090f commit 162597f

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

packages/firebase_ui_oauth_google/lib/src/provider.dart

+23-8
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ class GoogleProvider extends OAuthProvider {
1313
final providerId = 'google.com';
1414

1515
/// 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).
1718
final String clientId;
1819

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.
1926
final String? redirectUri;
27+
28+
/// The list of requested authroization scopes requested when signing in.
2029
final List<String>? scopes;
2130

2231
late GoogleSignIn provider;
@@ -37,25 +46,31 @@ class GoogleProvider extends OAuthProvider {
3746
required this.clientId,
3847
this.redirectUri,
3948
this.scopes,
49+
this.iOSPreferPlist = false,
4050
}) {
4151
firebaseAuthProvider.setCustomParameters(const {
4252
'prompt': 'select_account',
4353
});
4454

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 ?? []);
5157
} else {
5258
provider = GoogleSignIn(
53-
scopes: scopes ?? [],
5459
clientId: clientId,
60+
scopes: scopes ?? [],
5561
);
5662
}
5763
}
5864

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+
5974
@override
6075
void mobileSignIn(AuthAction action) async {
6176
provider.signIn().then((user) {

packages/firebase_ui_oauth_google/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
firebase_ui_oauth: ^1.1.10
1313
flutter:
1414
sdk: flutter
15-
google_sign_in: ^5.4.0
15+
google_sign_in: ^5.4.4
1616

1717
dev_dependencies:
1818
flutter_test:

0 commit comments

Comments
 (0)