appsup-dart / firebase_admin

A pure Dart implementation of the Firebase admin sdk
Other
44 stars 51 forks source link

Still can not access 'service-account.json' file #10

Closed ninjaprodev closed 4 years ago

ninjaprodev commented 4 years ago

I have tried two approaches. 1) Credentials.applicationDefault() --> returns null; 2) Credential credentials = FirebaseAdmin.instance.certFromPath("service-account.json"); --> throws FileNotFoundException

Here is an absolute path of my file: E:\Flutter_projects\Personal\authorization\service-account.json (root of the project) In case it tries to look into android app I also put this file here and here: E:\Flutter_projects\Personal\authorization\android\app\service-account.json E:\Flutter_projects\Personal\authorization\android\service-account.json

But it did not help :( What am I doing wrong?

ninjaprodev commented 4 years ago

I have tried two approaches.

  1. Credentials.applicationDefault() --> returns null;
  2. Credential credentials = FirebaseAdmin.instance.certFromPath("service-account.json"); --> throws FileNotFoundException

Here is an absolute path of my file: E:\Flutter_projects\Personal\authorization\service-account.json (root of the project) In case it tries to look into android app I also put this file here and here: E:\Flutter_projects\Personal\authorization\android\app\service-account.json E:\Flutter_projects\Personal\authorization\android\service-account.json

But it did not help :( What am I doing wrong?

Should have created the file first in the directory getApplicationDocumentsDirectory(), and then can access it also using this path: getApplicationDocumentsDirectory().path + name-of-file.json

getApplicationDirectory() from path_provider package