Flatter Firebase存储:没有用于请求的身份验证令牌

Flatter Firebase存储:没有用于请求的身份验证令牌,firebase,flutter,firebase-storage,Firebase,Flutter,Firebase Storage,我一直在尝试使用image_Picker将图像上载到Firebase存储 当我要将图像(图像文件)上载到Firebase存储时 Future uploadFile() async { StorageReference storageReference = storage.ref().child('profile/${Path.basename(imageFile.path)}}'); print('uploading..'); StorageUploa

我一直在尝试使用image_Picker将图像上载到Firebase存储

当我要将图像(图像文件)上载到Firebase存储时

 Future uploadFile() async {
    StorageReference storageReference =
        storage.ref().child('profile/${Path.basename(imageFile.path)}}');

    print('uploading..');
    StorageUploadTask uploadTask = storageReference.putFile(imageFile);

    //waiting for the image to upload
    await uploadTask.onComplete;

    print('File Uploaded');
    storageReference.getDownloadURL().then((fileURL) {
      setState(() {
        imageURL = fileURL;
      });
      print(imageURL);
    });
  }
但是,在上传过程中,出现一个错误,提示我没有身份验证令牌请求。 我以前使用过Firebase Auth将数据存储到数据库中,并且在那里所有配置都是正确的(我假设是这样,因为Firebase给了我一个google.json文件)


我还尝试将存储规则从读、写(如果是验证)更改为空以读取、写入。

检查firebase存储规则。我认为默认选项是只允许经过身份验证的用户。如果这是一个问题,只需将其更改为最适合您的需要。

您是否正在使用GoogleSignIn进行身份验证,您能否为firebase提供您的用户身份验证代码?对于GoogleSignIn方法,我遇到了相同的问题“无身份验证令牌请求”,我使用以下代码解决了此问题

final GoogleSignIn googleSignIn = GoogleSignIn();
FirebaseUser firebaseUser;
GoogleSignInAccount account = await googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth = await account.authentication;
final AuthCredential _cred = GoogleAuthProvider.getCredential(idToken: googleAuth.idToken, accessToken: googleAuth.accessToken);
final AuthResult _res = await FirebaseAuth.instance.signInWithCredential(_cred);
firebaseUser = _res.user;

那其实是我的问题,谢谢你的帮助answer@AhmedKhattab你设置了什么?你能分享一下规则吗?请允许我有同样的问题!我想这不仅仅是为了谷歌登录。。。但对于所有登录选项!!!
final GoogleSignIn googleSignIn = GoogleSignIn();
FirebaseUser firebaseUser;
GoogleSignInAccount account = await googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth = await account.authentication;
final AuthCredential _cred = GoogleAuthProvider.getCredential(idToken: googleAuth.idToken, accessToken: googleAuth.accessToken);
final AuthResult _res = await FirebaseAuth.instance.signInWithCredential(_cred);
firebaseUser = _res.user;