Firebase Storage ApiError: Forbidden #299 ... ApiError: Forbidden at new util

When, I want to utise firebstore for the frist time in the google cloud functions,  the main problem I had to face it the integration issue raise as follows.


 The google firebase and the google cloud storage eveloved seperately and in order to use the clould storage in firebase functions, the special autherntication need to be grantted even you are using firebase admin sdk.

ApiError: Forbidden    
at new util.ApiError (/user_code/node_modules/@google-cloud/storage/node_modules/@google-cloud/common/src/util.js:107:10)     
at Object.parseHttpRespMessage (/user_code/node_modules/@google-cloud/storage/node_modules/@google-cloud/common/src/util.js:149:33)     

I implemeted the firebase admin sdk as follows.

const firebaseAdmin = require("firebase-admin");
firebaseAdmin.initializeApp(functions.config().firebase);


And firebase cloud bucket implemented  as follows .

const storageRoot = firebaseAdmin.storage().bucket()

Google document also indicate authentication requirment but not clear
https://cloud.google.com/functions/docs/writing/http


However , the above error rise when we run the program to get the file content. The majour insight was given in below discussion, and thanks for contributors.

https://github.com/firebase/functions-samples/issues/299

You have to give the persmission to your clould funtion user ( <project_id>@@appspot.gserviceaccount.com) full acess to the storage as storage admin. In addition I grantted same prvildges to the sdk user (firebase-adminsdk-@<project_id>.iam.gserviceaccount.com) .

In order to reslove the issue, Navigate the storage section of the goolgle cloud console.

https://console.cloud.google.com/storage/browser?project=<project-id>,


Select the approprite backet for your project and click on info panel in top right.

Seach the above two users in the permission tab and grant the storage buacket admin privilages.



Comments

Popular posts from this blog

ENOENT: no such file or directory, rename : node_modules/async

react-quill Integrate quill-image-resize-module