'Firebase Storage Error - FIRStorageErrorDomain Code=-13021 "User does not have permission to access"

Im having a problem Iv been dealing with for a while. Basically im trying to grab images from Firebase Storage into my UICollectionView.

When i segue to that VC only 90% of images load. When I scroll down and scroll back up the rest load..im not sure why.

Here is the error code :

ResponseErrorDomain=com.google.HTTPStatus, data=<7b0a2020 22657272 6f72223a 207b0a20 20202022 636f6465 223a2034 30332c0a 20202020 226d6573 73616765 223a2022 44657665 6c6f7065 72206372 6564656e 7469616c 73207265 71756972 65642e22 0a20207d 0a7d>, bucket=project-355640.appspot.com, ResponseErrorCode=403, NSLocalizedDescription=User does not have permission to access gs://project-355640.appspot.com/(null).})
Optional(Error Domain=FIRStorageErrorDomain Code=-13021 "User does not have permission to access gs://project-3550640.appspot.com/(null)." UserInfo={ResponseBody={
  "error": {
    "code": 403,
    "message": "Developer credentials required.

Here is how the cells are created :

 func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

        let cell = collectionView.dequeueReusableCellWithReuseIdentifier("StoreViewCell", forIndexPath: indexPath)



        if let view = cell as? storeViewCell {

            //Problem is that every time we scroll the images are reloaded from server.
            /// See if yo ucan cache the images somehow and only use those images or cancel the reload.


            view.storeGunName.text = self.playerData.basicGunDict[indexPath.item]["model"]
            view.storeGunPrice.text = "$\(self.playerData.basicGunDict[indexPath.item]["price"]!)"

            if self.playerData.basicGunDict[indexPath.item]["available"] == "yes" {

                let currentImg = storageRef.child(self.playerData.basicGunDict[indexPath.item]["u-image"]!)

                currentImg.dataWithMaxSize(1 * 1024 * 1024, completion: {
                    (data, error) -> Void in

                    if (error != nil) {
                        print(error.debugDescription)
                    } else {
                        view.storeGunImage.image = UIImage(data: data!)
                    }

                })


            } else {

                let currentImg = storageRef.child(self.playerData.basicGunDict[indexPath.item]["l-image"]!)

                currentImg.dataWithMaxSize(1 * 1024 * 1024, completion: {
                    (data, error) -> Void in

                    if (error != nil) {
                        print(error.debugDescription)
                    } else {
                        view.storeGunImage.image = UIImage(data: data!)
                    }

                })

            }


            print("PER CELL \(self.playerData.basicGunDict[indexPath.item])")

        }
        return cell
    }



service firebase.storage {
  match /b/project-3550640.appspot.com/o {
    match /{allPaths=**} {
      allow read, write: if request.auth != null;
    }
  }
}


Solution 1:[1]

Firebase Console - > Storage - > Rules

Change if false -> if true

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vipinsaini0