From a3fbea26abeb4999811858a480004b769d3db9c1 Mon Sep 17 00:00:00 2001 From: zeeshanhussain Date: Fri, 22 May 2020 16:33:35 +0530 Subject: [PATCH 1/3] [google_sign_in] Fix serverAuthCode on Android --- .../google_sign_in/lib/google_sign_in.dart | 14 +++++++++++--- .../lib/src/types.dart | 11 ++++++++--- .../lib/src/utils.dart | 12 +++++++----- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart b/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart index 0f1f15bbb8c4..b25d1b8915eb 100644 --- a/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart +++ b/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart @@ -44,7 +44,8 @@ class GoogleSignInAccount implements GoogleIdentity { email = data.email, id = data.id, photoUrl = data.photoUrl, - _idToken = data.idToken { + _idToken = data.idToken, + _serverAuthCode = data.serverAuthCode { assert(id != null); } @@ -69,6 +70,7 @@ class GoogleSignInAccount implements GoogleIdentity { final String photoUrl; final String _idToken; + final String _serverAuthCode; final GoogleSignIn _googleSignIn; /// Retrieve [GoogleSignInAuthentication] for this account. @@ -97,6 +99,11 @@ class GoogleSignInAccount implements GoogleIdentity { if (response.idToken == null) { response.idToken = _idToken; } + + if (response.serverAuthCode == null) { + response.serverAuthCode = _serverAuthCode; + } + return GoogleSignInAuthentication._(response); } @@ -130,11 +137,12 @@ class GoogleSignInAccount implements GoogleIdentity { email == otherAccount.email && id == otherAccount.id && photoUrl == otherAccount.photoUrl && - _idToken == otherAccount._idToken; + _idToken == otherAccount._idToken && + _serverAuthCode == otherAccount._serverAuthCode; } @override - int get hashCode => hashValues(displayName, email, id, photoUrl, _idToken); + int get hashCode => hashValues(displayName, email, id, photoUrl, _idToken, _serverAuthCode); @override String toString() { 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 c60402200bdd..51cd8907365a 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 @@ -27,7 +27,7 @@ class GoogleSignInUserData { /// Uses the given data to construct an instance. Any of these parameters /// could be null. GoogleSignInUserData( - {this.displayName, this.email, this.id, this.photoUrl, this.idToken}); + {this.displayName, this.email, this.id, this.photoUrl, this.idToken, this.serverAuthCode}); /// The display name of the signed in user. /// @@ -62,9 +62,13 @@ class GoogleSignInUserData { /// data. String idToken; + /// Authorization code required to make API calls from the server. + /// Read more on + String serverAuthCode; + @override int get hashCode => - hashObjects([displayName, email, id, photoUrl, idToken]); + hashObjects([displayName, email, id, photoUrl, idToken, serverAuthCode]); @override bool operator ==(dynamic other) { @@ -75,7 +79,8 @@ class GoogleSignInUserData { otherUserData.email == email && otherUserData.id == id && otherUserData.photoUrl == photoUrl && - otherUserData.idToken == idToken; + otherUserData.idToken == idToken && + otherUserData.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 1ae828604af6..5518c803a9f9 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 @@ -10,11 +10,13 @@ GoogleSignInUserData getUserDataFromMap(Map data) { return null; } return GoogleSignInUserData( - displayName: data['displayName'], - email: data['email'], - id: data['id'], - photoUrl: data['photoUrl'], - idToken: data['idToken']); + displayName: data['displayName'], + email: data['email'], + id: data['id'], + photoUrl: data['photoUrl'], + idToken: data['idToken'], + serverAuthCode: data['serverAuthCode'], + ); } /// Converts token data coming from native code into the proper platform interface type. From 6873ffd93d386a72f7210a876a564d70fa81f23e Mon Sep 17 00:00:00 2001 From: zeeshanhussain Date: Fri, 22 May 2020 22:53:04 +0530 Subject: [PATCH 2/3] Update CHANGELOG and pubspec --- packages/google_sign_in/google_sign_in/CHANGELOG.md | 4 ++++ packages/google_sign_in/google_sign_in/pubspec.yaml | 2 +- .../google_sign_in_platform_interface/CHANGELOG.md | 4 ++++ .../google_sign_in_platform_interface/pubspec.yaml | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/google_sign_in/google_sign_in/CHANGELOG.md b/packages/google_sign_in/google_sign_in/CHANGELOG.md index 8fbba4944df7..3418fa00b01e 100644 --- a/packages/google_sign_in/google_sign_in/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.5.2 + +* Fix serverAuthCode on Android. + ## 4.5.1 * Add note on Apple sign in requirement in README. diff --git a/packages/google_sign_in/google_sign_in/pubspec.yaml b/packages/google_sign_in/google_sign_in/pubspec.yaml index 8e520334192c..a7de7a663a9e 100644 --- a/packages/google_sign_in/google_sign_in/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in/pubspec.yaml @@ -2,7 +2,7 @@ name: google_sign_in description: Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account on Android and iOS. homepage: https://github.com/flutter/plugins/tree/master/packages/google_sign_in/google_sign_in -version: 4.5.1 +version: 4.5.2 flutter: plugin: 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 aa8ad2cff80f..d251d97c91f7 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.3 + +* Added serverAuthCode in GoogleSignInUserData. + ## 1.1.2 * Update lower bound of dart dependency to 2.1.0. 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 7bc63d84110c..f7befb5ef99b 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 @@ description: A common platform interface for the google_sign_in plugin. 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.2 +version: 1.1.3 dependencies: flutter: From cd2e75bc4034d552cf2ab6d3ca30f5d2f07451e8 Mon Sep 17 00:00:00 2001 From: zeeshanhussain Date: Fri, 22 May 2020 22:59:04 +0530 Subject: [PATCH 3/3] Fix formatting --- .../google_sign_in/lib/google_sign_in.dart | 3 ++- .../lib/src/types.dart | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart b/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart index b25d1b8915eb..37c583c2d9f6 100644 --- a/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart +++ b/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart @@ -142,7 +142,8 @@ class GoogleSignInAccount implements GoogleIdentity { } @override - int get hashCode => hashValues(displayName, email, id, photoUrl, _idToken, _serverAuthCode); + int get hashCode => + hashValues(displayName, email, id, photoUrl, _idToken, _serverAuthCode); @override String toString() { 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 51cd8907365a..c034508fa591 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 @@ -27,7 +27,12 @@ class GoogleSignInUserData { /// Uses the given data to construct an instance. Any of these parameters /// could be null. GoogleSignInUserData( - {this.displayName, this.email, this.id, this.photoUrl, this.idToken, this.serverAuthCode}); + {this.displayName, + this.email, + this.id, + this.photoUrl, + this.idToken, + this.serverAuthCode}); /// The display name of the signed in user. /// @@ -67,8 +72,8 @@ class GoogleSignInUserData { String serverAuthCode; @override - int get hashCode => - hashObjects([displayName, email, id, photoUrl, idToken, serverAuthCode]); + int get hashCode => hashObjects( + [displayName, email, id, photoUrl, idToken, serverAuthCode]); @override bool operator ==(dynamic other) {