Skip to content

Commit e520b4c

Browse files
Make requesting server auth code optional (#68)
* Make requesting server auth code optional, fixing #67 * Update GoogleAuth.java Co-authored-by: Patryk Szalanski <[email protected]>
1 parent ecedab1 commit e520b4c

File tree

1 file changed

+5
-2
lines changed
  • android/src/main/java/com/codetrixstudio/capacitor/GoogleAuth

1 file changed

+5
-2
lines changed

android/src/main/java/com/codetrixstudio/capacitor/GoogleAuth/GoogleAuth.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class GoogleAuth extends Plugin {
2727
@Override
2828
public void load() {
2929
String clientId = this.getContext().getString(R.string.server_client_id);
30-
Boolean forceCodeForRefreshToken = false;
30+
boolean forceCodeForRefreshToken = false;
3131

3232
Boolean forceRefreshToken = (Boolean) getConfigValue("forceCodeForRefreshToken");
3333
if (forceRefreshToken != null) {
@@ -36,9 +36,12 @@ public void load() {
3636

3737
GoogleSignInOptions.Builder googleSignInBuilder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
3838
.requestIdToken(clientId)
39-
.requestServerAuthCode(clientId, forceCodeForRefreshToken)
4039
.requestEmail();
4140

41+
if (forceCodeForRefreshToken) {
42+
googleSignInBuilder.requestServerAuthCode(clientId, true);
43+
}
44+
4245
try {
4346
JSONArray scopeArray = (JSONArray) getConfigValue("scopes");
4447
Scope[] scopes = new Scope[scopeArray.length() - 1];

0 commit comments

Comments
 (0)