Firebase Storage 403 Error

1,964 views
Skip to first unread message

Oladetoun Gbemi

unread,
Feb 28, 2024, 4:48:14 PM2/28/24
to Firebase Google Group
I have a document on my firebase storage that I'm sharing with 3rd party. The document shares correctly and 3rd party can read but 3rd party can't write.

  const handleSave = async (_blob: Blob) => {
    // Log the writeToken to the console
  console.log('Write Token:', share.writeToken);
 
    // create storage file using signed url from share.token
    try {
      const response = await fetch(share.writeToken, {
        method: 'PUT',
        body: _blob,
      });
     
      if (!response.ok) {
        console.error('PUT request failed:', response.status, response.statusText);
        const errorText = await response.text();
        console.error('Error details:', errorText);
      }
    } catch (err) {
      console.error(err);
    }
  }


I keep getting this error
Shared.tsx:34 PUT request failed: 403
handleSave @ Shared.tsx:34
await in handleSave (async)
Shared.tsx:36 Error details: <?xml version='1.0' encoding='UTF-8'?><Error><Code>SignatureDoesNotMatch</Code><Message>Access denied.</Message><Details>The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.</Details><StringToSign>PUT

my developer.gserviceaccount.com has storage Admin access

My firebase storage rules is configuured for read and write access
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
        allow read, write: if true;
    }
  }
}
my cors.json is configured like this
[
    {
        "origin": ["*"],
        "method": ["GET", "PUT", "HEAD"],
        "maxAgeSeconds": 3600,
        "responseHeader": ["Content-Type", "Authorization"]
    }
]



Arthur Thompson

unread,
Feb 28, 2024, 5:44:47 PM2/28/24
to fireba...@googlegroups.com
Hi,

403 generally indicates that the server knows who you are but is not allowing you to access the resource. So I'm wondering if the rules you identify are actually applied.

When you go into the Firebase console do the storage rules there match what you have here?

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/14d568ff-93f7-44af-8db5-46acf0579bd7n%40googlegroups.com.

Oladetoun Gbemi

unread,
Feb 29, 2024, 12:05:01 PM2/29/24
to Firebase Google Group

Yes.
Here's a screenshot from my console
Screenshot 2024-02-29 at 10.17.30.jpg

Nohe

unread,
Feb 29, 2024, 7:23:11 PM2/29/24
to Firebase Google Group
Could you describe the documentation and API you are using to work with the storage buckets? I found some documentation on uploading over a URL, but that uses a POST request and I see you are using PUT. Is there a reason you are using PUT here instead of the documented POST?

-Nohe
Reply all
Reply to author
Forward
0 new messages