Skip to content

Commit af665ae

Browse files
authored
[google_sign_in_web] Add plugin_name to init call. (flutter#5242)
1 parent 7870605 commit af665ae

File tree

6 files changed

+45
-11
lines changed

6 files changed

+45
-11
lines changed

packages/google_sign_in/google_sign_in_web/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
## NEXT
1+
## 0.10.1
22

33
* Updates minimum Flutter version to 2.8.
4+
* Passes `plugin_name` to Google Sign-In's `init` method so new applications can
5+
continue using this plugin after April 30th 2022. Issue [#88084](https://github.com/flutter/flutter/issues/88084).
46

57
## 0.10.0+5
68

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'dart:html' as html;
6+
57
import 'package:flutter/services.dart';
68
import 'package:flutter_test/flutter_test.dart';
79
import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart';
@@ -126,6 +128,25 @@ void main() {
126128
throwsAssertionError);
127129
});
128130

131+
// See: https://github.com/flutter/flutter/issues/88084
132+
testWidgets('Init passes plugin_name parameter with the expected value',
133+
(WidgetTester tester) async {
134+
await plugin.init(
135+
hostedDomain: 'foo',
136+
scopes: <String>['some', 'scope'],
137+
clientId: '1234',
138+
);
139+
140+
final Object? initParameters =
141+
js_util.getProperty(html.window, 'gapi2.init.parameters');
142+
expect(initParameters, isNotNull);
143+
144+
final Object? pluginNameParameter =
145+
js_util.getProperty(initParameters!, 'plugin_name');
146+
expect(pluginNameParameter, isA<String>());
147+
expect(pluginNameParameter, 'dart-google_sign_in_web');
148+
});
149+
129150
group('Successful .init, then', () {
130151
setUp(() async {
131152
await plugin.init(

packages/google_sign_in/google_sign_in_web/example/integration_test/gapi_mocks/src/auth2_init.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ var mockUser = ${googleUser(userData)};
1212
1313
function GapiAuth2() {}
1414
GapiAuth2.prototype.init = function (initOptions) {
15+
/*Leak the initOptions so we can look at them later.*/
16+
window['gapi2.init.parameters'] = initOptions;
1517
return {
1618
then: (onSuccess, onError) => {
1719
window.setTimeout(() => {

packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class GoogleSignInPlugin extends GoogleSignInPlatform {
9292
// The js lib wants a space-separated list of values
9393
scope: scopes.join(' '),
9494
client_id: appClientId!,
95+
plugin_name: 'dart-google_sign_in_web',
9596
));
9697

9798
final Completer<void> isAuthInitialized = Completer<void>();

packages/google_sign_in/google_sign_in_web/lib/src/generated/gapiauth2.dart

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,23 @@ abstract class ClientConfig {
233233
/// The default redirect_uri is the current URL stripped of query parameters and hash fragment.
234234
external String? get redirect_uri;
235235
external set redirect_uri(String? v);
236-
external factory ClientConfig(
237-
{String client_id,
238-
String cookie_policy,
239-
String scope,
240-
bool fetch_basic_profile,
241-
String? hosted_domain,
242-
String openid_realm,
243-
String /*'popup'|'redirect'*/ ux_mode,
244-
String redirect_uri});
236+
237+
/// Allows newly created Client IDs to use the Google Platform Library from now until the March 30th, 2023 deprecation date.
238+
/// See: https://github.com/flutter/flutter/issues/88084
239+
external String? get plugin_name;
240+
external set plugin_name(String? v);
241+
242+
external factory ClientConfig({
243+
String client_id,
244+
String cookie_policy,
245+
String scope,
246+
bool fetch_basic_profile,
247+
String? hosted_domain,
248+
String openid_realm,
249+
String /*'popup'|'redirect'*/ ux_mode,
250+
String redirect_uri,
251+
String plugin_name,
252+
});
245253
}
246254

247255
@JS('gapi.auth2.SigninOptionsBuilder')

packages/google_sign_in/google_sign_in_web/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system
33
for signing in with a Google account on Android, iOS and Web.
44
repository: https://github.com/flutter/plugins/tree/main/packages/google_sign_in/google_sign_in_web
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
6-
version: 0.10.0+5
6+
version: 0.10.1
77

88
environment:
99
sdk: ">=2.12.0 <3.0.0"

0 commit comments

Comments
 (0)