firebase / firebase/firebase-admin-java

Parse GOOGLE_APPLICATION_CREDENTIALS as JSON if it begins with '{'

Open
#916 1 comment 0 reactions 0 assignees View on GitHub
needs-triage type: feature request
Dominant language
Java
Stars
620
Forks
305
Avg merge
3h 23m
Merged PRs (30d)
1

Description

**Is your feature request related to a problem? Please describe.**
I do not want to commit my credentials file to github, and when running my app inside another enviroment such as Heroku, i run into the trouble because even though i can specify ENV variables i must provide a file path for GOOGLE_APPLICATION_CREDENTIALS, which is inconvenient because im using git to deploy to heroku

**Describe the solution you'd like**
Parse GOOGLE_APPLICATION_CREDENTIALS as JSON if it begins with '{', otherwise assume is a file path.

**Describe alternatives you've considered**
Adding additional code that reads an env var which contains the credential json, this is inconvenient because i will need to copy and paste this code for all my projects that use firebase admin

```
fun createApp(): FirebaseApp {
val credentials = System.getenv("FIREBASE_CONFIG")
.byteInputStream()
.use { stream -> ServiceAccountCredentials.fromStream(stream) }
val config = FirebaseOptions.builder()
.setCredentials(credentials)
.build()
return FirebaseApp.initializeApp(config)
}
```

Contributor guide

Open the contributing guide

Research direction

Start by locating where GOOGLE_APPLICATION_CREDENTIALS is read and where service-account credentials are loaded in the Java SDK. Trace the existing file-path flow, then verify that values beginning with '{' are treated as credential JSON while other values remain file paths; done means both input forms work without committing a credentials file.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
authentication
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.