GithubHelp home page GithubHelp logo

Comments (5)

TennisDrum avatar TennisDrum commented on May 29, 2024

I'm getting this same error unless I change my Firebase Storage rules to allow all read/write. With the default rules (shown below). After I authorize a user via the FirbaseAuthentication.net process, I'm able to read and write to Firebase Database, but not Storage. I'm getting the 403: "Permission denied. Could not perform this operation" error.

Any help is appreciated.

Firebase Storage rules (these are the default rules):
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}
}
}

Firebase Login code (works for reads/writes to Database):

var auth = new FirebaseAuthProvider(new FirebaseConfig(firebaseApiKey));

            var token = await auth.SignInWithEmailAndPasswordAsync(firebaseUsername, firebasePassword);

            
            firebase = new FirebaseClient(
                                    firebaseUrl,
                                    new FirebaseOptions
                                    {
                                        AuthTokenAsyncFactory = () => Task.FromResult(token.FirebaseToken)
                                    });

            loginSuccessfulLabel.Text = "Login Successful";

Firebase storage code to upload .png image file (where 403 error is received). This same code works fine when Firebase storage rules are set to allow all read/write:

async void UploadImage_Clicked(object sender, System.EventArgs e)

        {
            var stream = File.Open("picture2.png", FileMode.Open);

            var task = new FirebaseStorage("xxxxxxx.appspot.com")
                .Child("data")
                .Child("picture2.png")
                .PutAsync(stream);

            task.Progress.ProgressChanged += (s, ex) => Console.WriteLine($"Progress: { ex.Percentage} %");

            downloadURL = await task;
        }

from firebase-storage-dotnet.

jaybowman avatar jaybowman commented on May 29, 2024

I'm having the same issue. I'm using my firebase server key. Same as when I create a FirebaseClient.
I get this error "Response status code does not indicate success: 403 (Forbidden)."
When I open up the storage rule to allow write: if true; I can save the file. Please help.

private async Task<string> SaveUserPhoto(string uid, Stream photoStream)
        {
            var task = new FirebaseStorage(_StorageBucket, new FirebaseStorageOptions()
                {
                    AuthTokenAsyncFactory = () => Task.FromResult(_firebaseServerKey)                    
                })
                .Child("residentPhotos")
                .Child(uid)
                .Child("profile.jpg")
                .PutAsync(photoStream);

            // Track progress of the upload
            task.Progress.ProgressChanged += (s, e) => Console.WriteLine($"Progress: {e.Percentage} %");

            // await the task to wait until upload completes and get the download url
            var downloadUrl = await task;

            return downloadUrl;
        }

from firebase-storage-dotnet.

jaybowman avatar jaybowman commented on May 29, 2024

I was able to authenticate using a user account. just follow the simpleConsole sample code. I would still be nice to use some type of service account.

from firebase-storage-dotnet.

stale avatar stale commented on May 29, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from firebase-storage-dotnet.

stale avatar stale commented on May 29, 2024

Closing the issue due to inactivity. Feel free to re-open

from firebase-storage-dotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.