Anthony Dito
Anthony Dito

Reputation: 3670

403 Trying to Upload to Firebase Storage via Firebase Cloud Function

I am receiving the following error when attempting to upload a file to storage.

[ { domain: 'global',
   reason: 'forbidden',
   message: '<name>@<app>.iam.gserviceaccount.com does not have storage.objects.create access to <app>.appspot.com/temp.txt.' } ]

Here is how I am doing the upload

const serviceAccount = require('./serviceaccount.json')
admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    storageBucket: "<app>.appspot.com"
})

const storage = admin.storage()
storage.bucket().upload('<my file path>')

My service account does have owner and storage admin access in IAM. So, my question is what am I doing wrong and/or what access do I need to give my service account to be able to upload files to Firebase Storage from Firebase Functions?

Upvotes: 1

Views: 483

Answers (1)

Anthony Dito
Anthony Dito

Reputation: 3670

Thanks to the comment of Doug Stevenson, what solved this for me was not specifying a service account and just using the default one.

admin.initializeApp()

Upvotes: 1

Related Questions