diff --git a/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOptions.java b/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOptions.java index ba79ee48c6ad..7eb23074a73b 100644 --- a/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOptions.java +++ b/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOptions.java @@ -208,6 +208,14 @@ public Builder setTimestampsInSnapshotsEnabled(boolean value) { @Override @Nonnull public FirestoreOptions build() { + if (this.credentials == null && this.credentialsProvider != null) { + try { + this.setCredentials(credentialsProvider.getCredentials()); + } catch (IOException e) { + throw new RuntimeException("Failed to obtain credentials", e); + } + } + return new FirestoreOptions(this); } }