[google_sign_in_platform_interface] Add serverAuthCode attribute. (#2634)
This change adds the `serverAuthCode` attribute to the `GoogleSignInTokenData` class.
Usage:
```
// Sign in somewhere, then...
final tokens = await _googleSignIn.getTokens();
final serverAuthCode = tokens.serverAuthCode;
// serverAuthCode may be used by your server
```
diff --git a/AUTHORS b/AUTHORS
index 35094d2..93d30ea 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -54,3 +54,4 @@
Giancarlo Rocha <giancarloiff@gmail.com>
Ryo Miyake <ryo@miyake.id>
Théo Champion <contact.theochampion@gmail.com>
+Kazuki Yamaguchi <y.kazuki0614n@gmail.com>
\ No newline at end of file
diff --git a/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md b/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md
index c0627df..c342c55 100644
--- a/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md
+++ b/packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.1.1
+
+* Add attribute serverAuthCode.
+
## 1.1.0
* Add hasRequestedScope method to determine if an Oauth scope has been granted.
diff --git a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart
index d69beb3..c604022 100644
--- a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart
+++ b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart
@@ -82,7 +82,11 @@
/// Holds authentication data after sign in.
class GoogleSignInTokenData {
/// Either or both parameters may be null.
- GoogleSignInTokenData({this.idToken, this.accessToken});
+ GoogleSignInTokenData({
+ this.idToken,
+ this.accessToken,
+ this.serverAuthCode,
+ });
/// An OpenID Connect ID token for the authenticated user.
String idToken;
@@ -90,8 +94,11 @@
/// The OAuth2 access token used to access Google services.
String accessToken;
+ /// Server auth code used to access Google Login
+ String serverAuthCode;
+
@override
- int get hashCode => hash2(idToken, accessToken);
+ int get hashCode => hash3(idToken, accessToken, serverAuthCode);
@override
bool operator ==(dynamic other) {
@@ -99,6 +106,7 @@
if (other is! GoogleSignInTokenData) return false;
final GoogleSignInTokenData otherTokenData = other;
return otherTokenData.idToken == idToken &&
- otherTokenData.accessToken == accessToken;
+ otherTokenData.accessToken == accessToken &&
+ otherTokenData.serverAuthCode == serverAuthCode;
}
}
diff --git a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/utils.dart b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/utils.dart
index eb60f00..1ae8286 100644
--- a/packages/google_sign_in/google_sign_in_platform_interface/lib/src/utils.dart
+++ b/packages/google_sign_in/google_sign_in_platform_interface/lib/src/utils.dart
@@ -25,5 +25,6 @@
return GoogleSignInTokenData(
idToken: data['idToken'],
accessToken: data['accessToken'],
+ serverAuthCode: data['serverAuthCode'],
);
}
diff --git a/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml b/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml
index d1f7abc..2484717 100644
--- a/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml
+++ b/packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml
@@ -3,7 +3,7 @@
homepage: https://github.com/flutter/plugins/tree/master/packages/google_sign_in/google_sign_in_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
-version: 1.1.0
+version: 1.1.1
dependencies:
flutter:
diff --git a/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart b/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart
index 6a8f7373..5ac34ad 100644
--- a/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart
+++ b/packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+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';
import 'package:google_sign_in_platform_interface/src/types.dart';
import 'package:google_sign_in_platform_interface/src/utils.dart';
-import 'package:flutter/services.dart';
-import 'package:flutter_test/flutter_test.dart';
const Map<String, String> kUserData = <String, String>{
"email": "john.doe@gmail.com",
@@ -18,6 +18,7 @@
const Map<dynamic, dynamic> kTokenData = <String, dynamic>{
'idToken': '123',
'accessToken': '456',
+ 'serverAuthCode': '789',
};
const Map<String, dynamic> kDefaultResponses = <String, dynamic>{