diff --git a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md index 810573ad697b..7dcf4e58531d 100644 --- a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md @@ -1,4 +1,8 @@ -## 0.12.2 +## 0.12.2+1 + +* Re-publishes `0.12.2` with a small fix to the CodeClient initialization. + +## 0.12.2 (withdrawn) * Adds server auth code retrieval to google_sign_in_web. * Adds `web_only` library to access web-only methods more easily. diff --git a/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart b/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart index a5ea642bc542..e88f797aa2e8 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart @@ -52,13 +52,15 @@ class GisSdkClient { onError: _onTokenError, ); - _codeClient = _initializeCodeClient( - clientId, - hostedDomain: hostedDomain, - onResponse: _onCodeResponse, - onError: _onCodeError, - scopes: initialScopes, - ); + if (initialScopes.isNotEmpty) { + _codeClient = _initializeCodeClient( + clientId, + hostedDomain: hostedDomain, + onResponse: _onCodeResponse, + onError: _onCodeError, + scopes: initialScopes, + ); + } } void _logIfEnabled(String message, [List? more]) { @@ -291,7 +293,13 @@ class GisSdkClient { /// Requests a server auth code per: /// https://developers.google.com/identity/oauth2/web/guides/use-code-model#initialize_a_code_client Future requestServerAuthCode() async { - _codeClient.requestCode(); + // TODO(dit): Enable granular authorization, https://github.com/flutter/flutter/issues/139406 + assert(_codeClient != null, + 'CodeClient not initialized correctly. Ensure the `scopes` list passed to `init()` or `initWithParams()` is not empty!'); + if (_codeClient == null) { + return null; + } + _codeClient!.requestCode(); final CodeResponse response = await _codeResponses.stream.first; return response.code; } @@ -461,7 +469,8 @@ class GisSdkClient { // The Google Identity Services client for oauth requests. late TokenClient _tokenClient; - late CodeClient _codeClient; + // CodeClient will not be created if `initialScopes` is empty. + CodeClient? _codeClient; // Streams of credential and token responses. late StreamController _credentialResponses; diff --git a/packages/google_sign_in/google_sign_in_web/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/pubspec.yaml index 7ce54286bea0..98d9ea5b573f 100644 --- a/packages/google_sign_in/google_sign_in_web/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_web/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account on Android, iOS and Web. repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 -version: 0.12.2 +version: 0.12.2+1 environment: sdk: ">=3.1.0 <4.0.0"