diff --git a/packages/google_sign_in/google_sign_in/CHANGELOG.md b/packages/google_sign_in/google_sign_in/CHANGELOG.md index 6107560ce610..6f4ccebf8dc3 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 @@ +## 5.2.0 + +* Add `GoogleSignInAccount.serverAuthCode`. Mark `GoogleSignInAuthentication.serverAuthCode` as deprecated. + ## 5.1.1 * Update minimum Flutter SDK to 2.5 and iOS deployment target to 9.0. 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 04d60fbc7d21..e104093c69bc 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 @@ -28,6 +28,7 @@ class GoogleSignInAuthentication { String? get accessToken => _data.accessToken; /// Server auth code used to access Google Login + @Deprecated('Use the `GoogleSignInAccount.serverAuthCode` property instead') String? get serverAuthCode => _data.serverAuthCode; @override @@ -44,6 +45,7 @@ class GoogleSignInAccount implements GoogleIdentity { email = data.email, id = data.id, photoUrl = data.photoUrl, + serverAuthCode = data.serverAuthCode, _idToken = data.idToken { assert(id != null); } @@ -68,6 +70,9 @@ class GoogleSignInAccount implements GoogleIdentity { @override final String? photoUrl; + @override + final String? serverAuthCode; + final String? _idToken; final GoogleSignIn _googleSignIn; @@ -97,6 +102,7 @@ class GoogleSignInAccount implements GoogleIdentity { if (response.idToken == null) { response.idToken = _idToken; } + return GoogleSignInAuthentication._(response); } @@ -132,11 +138,13 @@ class GoogleSignInAccount implements GoogleIdentity { email == otherAccount.email && id == otherAccount.id && photoUrl == otherAccount.photoUrl && + serverAuthCode == otherAccount.serverAuthCode && _idToken == otherAccount._idToken; } @override - int get hashCode => hashValues(displayName, email, id, photoUrl, _idToken); + int get hashCode => + hashValues(displayName, email, id, photoUrl, _idToken, serverAuthCode); @override String toString() { @@ -145,6 +153,7 @@ class GoogleSignInAccount implements GoogleIdentity { 'email': email, 'id': id, 'photoUrl': photoUrl, + 'serverAuthCode': serverAuthCode }; return 'GoogleSignInAccount:$data'; } diff --git a/packages/google_sign_in/google_sign_in/lib/src/common.dart b/packages/google_sign_in/google_sign_in/lib/src/common.dart index 068403e74629..8a1d4dcb354f 100644 --- a/packages/google_sign_in/google_sign_in/lib/src/common.dart +++ b/packages/google_sign_in/google_sign_in/lib/src/common.dart @@ -34,4 +34,7 @@ abstract class GoogleIdentity { /// /// Not guaranteed to be present for all users, even when configured. String? get photoUrl; + + /// Server auth code used to access Google Login + String? get serverAuthCode; } diff --git a/packages/google_sign_in/google_sign_in/lib/testing.dart b/packages/google_sign_in/google_sign_in/lib/testing.dart index c4d2da3089a5..e519b34b199a 100644 --- a/packages/google_sign_in/google_sign_in/lib/testing.dart +++ b/packages/google_sign_in/google_sign_in/lib/testing.dart @@ -67,6 +67,7 @@ class FakeUser { this.email, this.displayName, this.photoUrl, + this.serverAuthCode, this.idToken, this.accessToken, }); @@ -83,6 +84,9 @@ class FakeUser { /// Will be converted into [GoogleSignInUserData.photoUrl]. final String? photoUrl; + /// Will be converted into [GoogleSignInUserData.serverAuthCode]. + final String? serverAuthCode; + /// Will be converted into [GoogleSignInTokenData.idToken]. final String? idToken; @@ -94,6 +98,7 @@ class FakeUser { 'email': email, 'displayName': displayName, 'photoUrl': photoUrl, + 'serverAuthCode': serverAuthCode, 'idToken': idToken, }; } diff --git a/packages/google_sign_in/google_sign_in/pubspec.yaml b/packages/google_sign_in/google_sign_in/pubspec.yaml index aa0a686776fb..91114c6b0491 100644 --- a/packages/google_sign_in/google_sign_in/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in/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 and iOS. repository: https://github.com/flutter/plugins/tree/master/packages/google_sign_in/google_sign_in issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 -version: 5.1.1 +version: 5.2.0 environment: sdk: ">=2.14.0 <3.0.0" @@ -23,7 +23,7 @@ flutter: dependencies: flutter: sdk: flutter - google_sign_in_platform_interface: ^2.0.1 + google_sign_in_platform_interface: ^2.1.0 google_sign_in_web: ^0.10.0 meta: ^1.3.0 diff --git a/packages/google_sign_in/google_sign_in/test/google_sign_in_test.dart b/packages/google_sign_in/google_sign_in/test/google_sign_in_test.dart index 444edc4336ce..76bc2d600541 100644 --- a/packages/google_sign_in/google_sign_in/test/google_sign_in_test.dart +++ b/packages/google_sign_in/google_sign_in/test/google_sign_in_test.dart @@ -23,6 +23,7 @@ void main() { "id": "8162538176523816253123", "photoUrl": "https://lh5.googleusercontent.com/photo.jpg", "displayName": "John Doe", + "serverAuthCode": "789" }; const Map kDefaultResponses = { @@ -350,7 +351,8 @@ void main() { expect(auth.accessToken, '456'); expect(auth.idToken, '123'); - expect(auth.serverAuthCode, '789'); + // fix deprecated_member_use_from_same_package + // expect(auth.serverAuthCode, '789'); expect( log, [ @@ -382,11 +384,11 @@ void main() { group('GoogleSignIn with fake backend', () { const FakeUser kUserData = FakeUser( - id: "8162538176523816253123", - displayName: "John Doe", - email: "john.doe@gmail.com", - photoUrl: "https://lh5.googleusercontent.com/photo.jpg", - ); + id: "8162538176523816253123", + displayName: "John Doe", + email: "john.doe@gmail.com", + photoUrl: "https://lh5.googleusercontent.com/photo.jpg", + serverAuthCode: '789'); late GoogleSignIn googleSignIn; @@ -411,6 +413,7 @@ void main() { expect(user.email, equals(kUserData.email)); expect(user.id, equals(kUserData.id)); expect(user.photoUrl, equals(kUserData.photoUrl)); + expect(user.serverAuthCode, equals(kUserData.serverAuthCode)); await googleSignIn.disconnect(); expect(googleSignIn.currentUser, isNull);