CoastalB
CoastalB

Reputation: 745

Flutter Firebase Storage returning FirebaseApiNotAvailableException

From a Flutter app, I am trying to determine the download URL of an image within Firebase Storage. For testing, there are no auth security rules applied (set as 'allow read, write;') or auth applied in the app. When using the following method,

Future<String> _getDownloadImageUrl(String folder, String filename) async {
  String childpath = "$folder/$filename";
  StorageReference ref = FirebaseStorage.instance.ref().child(childpath);
  Future<String> durl = await ref.getDownloadURL();
  return durl;
}

I get the following error (when testing on Android device) :

E/StorageUtil(): error getting token java.util.concurrent.ExecutionException: com.google.firebase.FirebaseApiNotAvailableException: firebase-auth is not linked, please fall back to unauthenticated mode.

The same app is querying (Firestore) database data OK (with no auth), but I'm not sure if I am missing a step, for example, such as explicitly performing an action relating to "unauthenticated mode" for Firebase Storage?

Upvotes: 1

Views: 1491

Answers (1)

SaMiCoOo
SaMiCoOo

Reputation: 367

Did you check your firebase storage rules?

You can find it in the rules tab on the storage page (shown below)

enter image description here

you will need to change

allow read, write: if request.auth!=null;

to

allow read, write: if true;

and check, but you will obviously want to change that before going to production.

With that aside you have a little typo in your code

Future<String> durl = await ref.getDownloadURL();

should be

String durl = await ref.getDownloadURL();
/// you can also use `final` and type inference will do the work for you.

Upvotes: 1

Related Questions