Description
I recently upgraded Firestore from version 0.51.0-beta to 0.52.0-beta, which allows overriding of various options. My instantiation broke and now throws this exception:
com.google.cloud.firestore.FirestoreException: java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
My previous service instantiation code looked like this:
GoogleCredentials creds = getServiceAccountCredentialsFromFile();
Firestore firestore = new DefaultFirestoreFactory()
.create(
FirestoreOptions.newBuilder()
.setCredentials(creds)
.setProjectId(projectId)
.build());
After upgrading this config no longer works; I have to do something like this:
Firestore firestore = new DefaultFirestoreFactory()
.create(
FirestoreOptions.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(creds))
.setProjectId(projectId)
.build());
I have also tried this:
Firestore firestore = new DefaultFirestoreFactory()
.create(
FirestoreOptions.newBuilder()
.setCredentials(creds)
.setProjectId(config.getString("firestore.projectId"))
.setCredentialsProvider(FirestoreOptions.getDefaultCredentialsProviderBuilder().build())
.build());
but this also did not work.
Is it expected that setCredentials()
is effectively ignored?