Skip to content

Allow setting default_web_client_id at runtime #1953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 14, 2021
Merged
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
14 changes: 12 additions & 2 deletions auth/src/main/java/com/firebase/ui/auth/AuthUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,9 @@ private String getDefaultIso() {
public static final class GoogleBuilder extends Builder {
public GoogleBuilder() {
super(GoogleAuthProvider.PROVIDER_ID);
}

private void validateWebClientId() {
Preconditions.checkConfigured(getApplicationContext(),
"Check your google-services plugin configuration, the" +
" default_web_client_id string wasn't populated.",
Expand Down Expand Up @@ -1103,8 +1106,14 @@ public GoogleBuilder setSignInOptions(@NonNull GoogleSignInOptions options) {
ExtraConstants.GOOGLE_SIGN_IN_OPTIONS);

GoogleSignInOptions.Builder builder = new GoogleSignInOptions.Builder(options);
builder.requestEmail().requestIdToken(getApplicationContext()
.getString(R.string.default_web_client_id));

String clientId = options.getServerClientId();
if (clientId == null) {
validateWebClientId();
clientId = getApplicationContext().getString(R.string.default_web_client_id);
}

builder.requestEmail().requestIdToken(clientId);
getParams().putParcelable(
ExtraConstants.GOOGLE_SIGN_IN_OPTIONS, builder.build());

Expand All @@ -1115,6 +1124,7 @@ public GoogleBuilder setSignInOptions(@NonNull GoogleSignInOptions options) {
@Override
public IdpConfig build() {
if (!getParams().containsKey(ExtraConstants.GOOGLE_SIGN_IN_OPTIONS)) {
validateWebClientId();
setScopes(Collections.<String>emptyList());
}

Expand Down