[google_sign_in_web] Add `plugin_name` to `init` call. (#5242)
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 e35caf7..aab4aca 100644
--- a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md
+++ b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md
@@ -1,6 +1,8 @@
-## NEXT
+## 0.10.1
* Updates minimum Flutter version to 2.8.
+* Passes `plugin_name` to Google Sign-In's `init` method so new applications can
+ continue using this plugin after April 30th 2022. Issue [#88084](https://github.com/flutter/flutter/issues/88084).
## 0.10.0+5
diff --git a/packages/google_sign_in/google_sign_in_web/example/integration_test/auth2_test.dart b/packages/google_sign_in/google_sign_in_web/example/integration_test/auth2_test.dart
index 2af9476..9db0243 100644
--- a/packages/google_sign_in/google_sign_in_web/example/integration_test/auth2_test.dart
+++ b/packages/google_sign_in/google_sign_in_web/example/integration_test/auth2_test.dart
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'dart:html' as html;
+
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart';
@@ -126,6 +128,25 @@
throwsAssertionError);
});
+ // See: https://github.com/flutter/flutter/issues/88084
+ testWidgets('Init passes plugin_name parameter with the expected value',
+ (WidgetTester tester) async {
+ await plugin.init(
+ hostedDomain: 'foo',
+ scopes: <String>['some', 'scope'],
+ clientId: '1234',
+ );
+
+ final Object? initParameters =
+ js_util.getProperty(html.window, 'gapi2.init.parameters');
+ expect(initParameters, isNotNull);
+
+ final Object? pluginNameParameter =
+ js_util.getProperty(initParameters!, 'plugin_name');
+ expect(pluginNameParameter, isA<String>());
+ expect(pluginNameParameter, 'dart-google_sign_in_web');
+ });
+
group('Successful .init, then', () {
setUp(() async {
await plugin.init(
diff --git a/packages/google_sign_in/google_sign_in_web/example/integration_test/gapi_mocks/src/auth2_init.dart b/packages/google_sign_in/google_sign_in_web/example/integration_test/gapi_mocks/src/auth2_init.dart
index cc49b27..84f4e6e 100644
--- a/packages/google_sign_in/google_sign_in_web/example/integration_test/gapi_mocks/src/auth2_init.dart
+++ b/packages/google_sign_in/google_sign_in_web/example/integration_test/gapi_mocks/src/auth2_init.dart
@@ -12,6 +12,8 @@
function GapiAuth2() {}
GapiAuth2.prototype.init = function (initOptions) {
+ /*Leak the initOptions so we can look at them later.*/
+ window['gapi2.init.parameters'] = initOptions;
return {
then: (onSuccess, onError) => {
window.setTimeout(() => {
diff --git a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart
index 731ced5..533c353 100644
--- a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart
+++ b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart
@@ -92,6 +92,7 @@
// The js lib wants a space-separated list of values
scope: scopes.join(' '),
client_id: appClientId!,
+ plugin_name: 'dart-google_sign_in_web',
));
final Completer<void> isAuthInitialized = Completer<void>();
diff --git a/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart b/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart
index 88d196b..8e23713 100644
--- a/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart
+++ b/packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart
@@ -233,15 +233,23 @@
/// The default redirect_uri is the current URL stripped of query parameters and hash fragment.
external String? get redirect_uri;
external set redirect_uri(String? v);
- external factory ClientConfig(
- {String client_id,
- String cookie_policy,
- String scope,
- bool fetch_basic_profile,
- String? hosted_domain,
- String openid_realm,
- String /*'popup'|'redirect'*/ ux_mode,
- String redirect_uri});
+
+ /// Allows newly created Client IDs to use the Google Platform Library from now until the March 30th, 2023 deprecation date.
+ /// See: https://github.com/flutter/flutter/issues/88084
+ external String? get plugin_name;
+ external set plugin_name(String? v);
+
+ external factory ClientConfig({
+ String client_id,
+ String cookie_policy,
+ String scope,
+ bool fetch_basic_profile,
+ String? hosted_domain,
+ String openid_realm,
+ String /*'popup'|'redirect'*/ ux_mode,
+ String redirect_uri,
+ String plugin_name,
+ });
}
@JS('gapi.auth2.SigninOptionsBuilder')
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 d97a7c4..5a09453 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 @@
for signing in with a Google account on Android, iOS and Web.
repository: https://github.com/flutter/plugins/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.10.0+5
+version: 0.10.1
environment:
sdk: ">=2.12.0 <3.0.0"