user2297136
user2297136

Reputation: 23

FirebaseCredentials.fromCertificate(serviceAccount) has Failed to parse service account: 'project_id' must be set JSONException

Java mavern application: When executing the following code firebaseCredential has stream exception cause set message with

"Failed to parse service account: 'project_id' must be set"

attached is the watch screen. NOTE: google-services.json file is downloaded in firebase console. Any help is appreciated.

Stacktrace:

1

 FileInputStream serviceAccount = new FileInputStream("src/main/resources/google-services.json");
 FirebaseCredential firebaseCredential = FirebaseCredentials.fromCertificate(serviceAccount); //  FirebaseCredentials.applicationDefault();
 FirebaseOptions options = new FirebaseOptions.Builder()

Upvotes: 2

Views: 510

Answers (1)

Sam
Sam

Reputation: 418

You've downloaded the wrong credential Json file. Instead of getting the one in Project settings -> General, you should get it from Project settings -> Service Accounts and generate a new private key. It should generate for you a new Json file with the correct credentials in it.

Upvotes: 2

Related Questions