简体   繁体   中英

Firebase Storage Exception when fetching downloadUrl [Flutter]

When trying to use FireBase Cloud Storage to get a video downloadUrl

final storage = FirebaseStorage.instance;
downloadUrl() async {
  final downloadUrl =
      await storage.ref("User_uploadVideo/videoplayback.mp4").getDownloadURL();
  return downloadUrl;
}

An exception is thrown saying Exception: [firebase_storage/unauthenticated] User is unauthenticated. Authenticate and try again. Exception: [firebase_storage/unauthenticated] User is unauthenticated. Authenticate and try again.

Even tho I have opened the security rules to public for development.

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write;
    }
  }
}

Try this:

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write: if true;
    }
  }
}

main.dart

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  ); 
...

Also, make sure to have AppCheck disabled.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM