-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[google_sign_in] Add ability to return serverAuthCode #2116
Changes from 12 commits
36f7fd0
9350ff9
722959c
55ce6a4
9efd8c4
73f6fa0
df155e5
66f969c
3ed41e7
97cbf5b
a24a547
dba9fde
beed787
9eb338c
5227ce8
0cc73de
d77b480
29d0503
e4886ad
3ce141f
5eaa11a
580b5a6
cbe903e
95a2969
428a12f
10d90fc
7177136
a1b3655
7c7d0a7
866e356
1381e78
39ce20b
1c3b37b
42b6410
bfc4d8e
f0cc548
6deb8cf
4cf79ac
a373bf7
e48ff2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 4.0.10 | ||
|
||
* Added support for getting `serverAuthCode` | ||
|
||
## 4.0.9 | ||
|
||
* Update and migrate iOS example project. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cyanglaz There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)); | ||
|
@@ -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()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
} | ||
|
@@ -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); | ||
} | ||
|
||
|
@@ -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. | ||
|
@@ -91,6 +97,10 @@ class GoogleSignInAccount implements GoogleIdentity { | |
if (response['idToken'] == null) { | ||
response['idToken'] = _idToken; | ||
} | ||
|
||
if (response['serverAuthCode'] == null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nits: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's cool |
||
response['serverAuthCode'] = _serverAuthCode; | ||
} | ||
return GoogleSignInAuthentication._(response); | ||
} | ||
|
||
|
@@ -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 | ||
|
There was a problem hiding this comment.
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