Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[google_sign_in] Add serverAuthCode attribute to google_sign_in_platform_interface user data #4179

Merged
merged 7 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.1.0

* Add serverAuthCode attribute to user data

## 2.0.1

* Updates `init` function in `MethodChannelGoogleSignIn` to parametrize `clientId` property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class GoogleSignInUserData {
this.displayName,
this.photoUrl,
this.idToken,
this.serverAuthCode,
});

/// The display name of the signed in user.
Expand Down Expand Up @@ -66,9 +67,12 @@ class GoogleSignInUserData {
/// data.
String? idToken;

/// Server auth code used to access Google Login
String? serverAuthCode;

@override
int get hashCode =>
hashObjects(<String?>[displayName, email, id, photoUrl, idToken]);
int get hashCode => hashObjects(
<String?>[displayName, email, id, photoUrl, idToken, serverAuthCode]);

@override
bool operator ==(dynamic other) {
Expand All @@ -79,7 +83,8 @@ class GoogleSignInUserData {
otherUserData.email == email &&
otherUserData.id == id &&
otherUserData.photoUrl == photoUrl &&
otherUserData.idToken == idToken;
otherUserData.idToken == idToken &&
otherUserData.serverAuthCode == serverAuthCode;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ GoogleSignInUserData? getUserDataFromMap(Map<String, dynamic>? data) {
id: data['id']!,
displayName: data['displayName'],
photoUrl: data['photoUrl'],
idToken: data['idToken']);
idToken: data['idToken'],
serverAuthCode: data['serverAuthCode']);
}

/// Converts token data coming from native code into the proper platform interface type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/master/packages/google_sign_
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
# 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: 2.0.1
version: 2.1.0

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const Map<String, String> kUserData = <String, String>{
"id": "8162538176523816253123",
"photoUrl": "https://lh5.googleusercontent.com/photo.jpg",
"displayName": "John Doe",
'idToken': '123',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the test data gets validated anywhere. I'd imagine there should be something like;

expect(user.serverAuthCode, kUserData['serverAuthCode']);

(Thanks for adding the idToken)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check #4179 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh make sense, thanks

'serverAuthCode': '789',
};

const Map<dynamic, dynamic> kTokenData = <String, dynamic>{
Expand Down