Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Application Default Credentials take precedence over EmulatorCredentials

Open
#634 2 comments 4 reactions 1 assignee View on GitHub

@yuchenshi is already working on this.

Since Jan 26, 2022.

Assessment

This issue has not been assessed yet.

Description

api: firestore type: bug
Environment
  • Operating System version: Fedora 35
  • Firebase SDK version: Firebase Admin Java
  • Library version: 8.1.0
  • Firebase Product: firestore
Problem

If I have an Application Default Credentials File in ~/.config/gcloud/ than I get a warning about using user credentials for a server application while running my test against the emulator.
I do not expect to get this message as I am initializing the SDK with credentials provided and Javadoc for the Firestore Builder states that Application Defaults are only taken if Credentials are null.

Steps to reproduce:

Initialize the SDK in a Junit test like stated below.

Starting the test, the SDK will log the following message if there are Application Default Credentials:
"WARN com.google.auth.oauth2.DefaultCredentialsProvider - Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/."

Though, the test itself seems to run against the emulator just fine. Once I remove the Credentials by moving the credentials file, the test runs without warning.

Relevant Code:
private val firestoreEmulator: Firestore by lazy {
		FirestoreOptions.getDefaultInstance().toBuilder()
			.setEmulatorHost(emulator.emulatorEndpoint)
			.setCredentials(FirestoreOptions.EmulatorCredentials())
			.setProjectId("demo-project")
			.build().service
	}
Dominant language
Java
Stars
620
Forks
305
Avg merge
4d 9h
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from firebase/firebase-admin-java

All issues in firebase/firebase-admin-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.