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

[google_sign_in] Add ability to return serverAuthCode #2116

Merged
merged 40 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
36f7fd0
Update GoogleSignInPlugin.java
yamarkz Sep 27, 2019
9350ff9
Update GoogleSignInPlugin.m
yamarkz Sep 27, 2019
722959c
Update google_sign_in.dart
yamarkz Sep 27, 2019
55ce6a4
Update version number
yamarkz Sep 27, 2019
9efd8c4
Update AUTHORS
yamarkz Sep 27, 2019
73f6fa0
Update CHANGELOG.md
yamarkz Sep 27, 2019
df155e5
Update GoogleSignInPlugin.java
yamarkz Sep 27, 2019
66f969c
Update GoogleSignInPlugin.m
yamarkz Sep 27, 2019
3ed41e7
Update google_sign_in.dart
yamarkz Sep 27, 2019
97cbf5b
Update AUTHORS
yamarkz Sep 27, 2019
a24a547
Update CHANGELOG.md
yamarkz Sep 27, 2019
dba9fde
modify conflict
yamarkz Sep 27, 2019
beed787
modify variable assignment
yamarkz Nov 8, 2019
9eb338c
fix conflict
yamarkz Nov 8, 2019
5227ce8
add test case
yamarkz Nov 8, 2019
0cc73de
pubspec version up
yamarkz Nov 8, 2019
d77b480
Update CHANGELOG.md
yamarkz Nov 8, 2019
29d0503
fix conflict
yamarkz Nov 15, 2019
e4886ad
modify conflict
yamarkz Dec 16, 2019
3ce141f
Merge branch 'master' into server-auth-code
yamarkz Dec 16, 2019
5eaa11a
fix changelog conflict
yamarkz Jan 10, 2020
580b5a6
Merge branch 'master' into server-auth-code
yamarkz Mar 30, 2020
cbe903e
modify return values
yamarkz Mar 30, 2020
95a2969
modify conflict
yamarkz Mar 30, 2020
428a12f
modify conflict
yamarkz Apr 6, 2020
10d90fc
modify conflict
yamarkz Apr 8, 2020
7177136
update ios/android example code
yamarkz Apr 8, 2020
a1b3655
modify conflict
yamarkz Apr 24, 2020
7c7d0a7
update interface package version
yamarkz Apr 24, 2020
866e356
remove interface code
yamarkz Apr 24, 2020
1381e78
add attribute description comment
yamarkz Apr 24, 2020
39ce20b
remove extra line
yamarkz Apr 24, 2020
1c3b37b
remove unnecessary code
yamarkz Apr 24, 2020
42b6410
modify attribute
yamarkz Apr 24, 2020
bfc4d8e
update package version
yamarkz Apr 24, 2020
f0cc548
modify CHANGELOG.md
yamarkz Apr 25, 2020
6deb8cf
add EOF line
yamarkz Apr 25, 2020
4cf79ac
modify conflict
yamarkz Apr 30, 2020
a373bf7
use v2 embedding context
yamarkz Apr 30, 2020
e48ff2c
modify conflict file
yamarkz May 18, 2020
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
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ Audrius Karosevicius <[email protected]>
Lukasz Piliszczuk <[email protected]>
SoundReply Solutions GmbH <[email protected]>
Rafal Wachol <[email protected]>
Pau Picas <[email protected]>
Pau Picas <[email protected]>
Kazuki Yamaguchi <[email protected]>
4 changes: 4 additions & 0 deletions packages/google_sign_in/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.0.10
Copy link
Contributor

Choose a reason for hiding this comment

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

This patch actually updated the response of the public API so it should be 4.1.0


* Added support for getting `serverAuthCode`

## 4.0.9

* Update and migrate iOS example project.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ public void init(
"default_web_client_id", "string", registrar.context().getPackageName());
if (clientIdIdentifier != 0) {
optionsBuilder.requestIdToken(registrar.context().getString(clientIdIdentifier));
optionsBuilder.requestServerAuthCode(registrar.context().getString(clientIdIdentifier));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the serverClientId always static? We might want to have it be able to set through code as well. Same in iOS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cyanglaz
Thank you for review and comment. I'm going to modify them.
About here, In my opinion I think serverClientId is static define, because it is not dynamic value.
but if you have idea or opinion, i give priority to them. please tell me :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

returning serverAuthCode is using my flutter app. so I'm positive about support this modify.

Copy link
Contributor Author

@yamarkz yamarkz Nov 8, 2019

Choose a reason for hiding this comment

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

and return null if SERVER_CLIENT_ID value is null.

}
for (String scope : requestedScopes) {
optionsBuilder.requestScopes(new Scope(scope));
Expand Down Expand Up @@ -360,6 +361,7 @@ private void onSignInAccount(GoogleSignInAccount account) {
response.put("email", account.getEmail());
response.put("id", account.getId());
response.put("idToken", account.getIdToken());
response.put("serverAuthCode", account.getServerAuthCode());
response.put("displayName", account.getDisplayName());
if (account.getPhotoUrl() != null) {
response.put("photoUrl", account.getPhotoUrl().toString());
Expand Down
4 changes: 4 additions & 0 deletions packages/google_sign_in/ios/Classes/GoogleSignInPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
// for more info.
static NSString *const kClientIdKey = @"CLIENT_ID";

static NSString *const kServerClientIdKey = @"SERVER_CLIENT_ID";

// These error codes must match with ones declared on Android and Dart sides.
static NSString *const kErrorReasonSignInRequired = @"sign_in_required";
static NSString *const kErrorReasonSignInCanceled = @"sign_in_canceled";
Expand Down Expand Up @@ -73,6 +75,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
if (path) {
NSMutableDictionary *plist = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
[GIDSignIn sharedInstance].clientID = plist[kClientIdKey];
[GIDSignIn sharedInstance].serverClientID = plist[kServerClientIdKey];
[GIDSignIn sharedInstance].scopes = call.arguments[@"scopes"];
[GIDSignIn sharedInstance].hostedDomain = call.arguments[@"hostedDomain"];
result(nil);
Expand Down Expand Up @@ -173,6 +176,7 @@ - (void)signIn:(GIDSignIn *)signIn
@"email" : user.profile.email ?: [NSNull null],
@"id" : user.userID ?: [NSNull null],
@"photoUrl" : [photoUrl absoluteString] ?: [NSNull null],
@"serverAuthCode" : user.serverAuthCode ?: [NSNull null]
}
error:nil];
}
Expand Down
15 changes: 13 additions & 2 deletions packages/google_sign_in/lib/google_sign_in.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class GoogleSignInAuthentication {
/// The OAuth2 access token to access Google services.
String get accessToken => _data['accessToken'];

String get serverAuthCode => _data['serverAuthCode'];

@override
String toString() => 'GoogleSignInAuthentication:$_data';
}
Expand All @@ -36,7 +38,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);
}

Expand All @@ -61,6 +64,9 @@ class GoogleSignInAccount implements GoogleIdentity {
final String photoUrl;

final String _idToken;

final String _serverAuthCode;

final GoogleSignIn _googleSignIn;

/// Retrieve [GoogleSignInAuthentication] for this account.
Expand Down Expand Up @@ -91,6 +97,10 @@ class GoogleSignInAccount implements GoogleIdentity {
if (response['idToken'] == null) {
response['idToken'] = _idToken;
}

if (response['serverAuthCode'] == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nits: response['serverAuthCode'] ??=_serverAuthCode;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's cool

response['serverAuthCode'] = _serverAuthCode;
}
return GoogleSignInAuthentication._(response);
}

Expand Down Expand Up @@ -123,7 +133,8 @@ class GoogleSignInAccount implements GoogleIdentity {
email == otherAccount.email &&
id == otherAccount.id &&
photoUrl == otherAccount.photoUrl &&
_idToken == otherAccount._idToken;
_idToken == otherAccount._idToken &&
_serverAuthCode == otherAccount._serverAuthCode;
}

@override
Expand Down