Skip to content

Commit d7915e1

Browse files
committed
always set webclientId
update readme
1 parent 64f17b3 commit d7915e1

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

Plugins/Android/src/main/java/com/google/googlesignin/GoogleSignInHelper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public Task<AuthorizationResult> apply(@NonNull Boolean silent) {
157157
if(defaultAccountName != null)
158158
getGoogleIdOptionBuilder.setNonce(defaultAccountName);
159159

160-
if(requestIdToken && !Strings.isEmptyOrWhitespace(webClientId))
160+
if(!Strings.isEmptyOrWhitespace(webClientId))
161161
getGoogleIdOptionBuilder.setServerClientId(webClientId);
162162

163163
GetCredentialRequest.Builder getCredentialRequestBuilder = new GetCredentialRequest.Builder()

README.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,23 @@ Android was migrated to use `CredentialManager` and `AuthorizationClient` since
99

1010
However, `GoogleIdTokenCredential` actually not provide numeric unique ID anymore and set email as userId instead, so I have to extract jwt `sub` value from idToken (which seem like the same id as userId from GoogleSignIn of other platform)
1111

12-
Also, this new system seem like it did not support email hint
12+
Also, this new system seem like it did not support email hint. And now require WebClientId in addition to Android Client ID. Which need to provided at configuration initialization
13+
14+
```C#
15+
GoogleSignIn.Configuration = new GoogleSignInConfiguration() {
16+
RequestEmail = true,
17+
RequestProfile = true,
18+
RequestIdToken = true,
19+
RequestAuthCode = true,
20+
// must be web client ID, not android client ID
21+
WebClientId = "XXXXXXXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
22+
#if UNITY_EDITOR || UNITY_STANDALONE
23+
ClientSecret = "XXXXXX-xxxXXXxxxXXXxxx-xxxxXXXXX" // optional for windows/macos and test in editor
24+
#endif
25+
};
26+
```
1327

14-
Tested in unity 2021.3.21 and unity 6000.0.4
28+
Tested in unity 2021.3.21 and unity 6000.0.5
1529

1630
Add UPM dependency with branch tag `https://github.com/Thaina/google-signin-unity.git#newmigration`
1731

0 commit comments

Comments
 (0)