3
votes

I create buckets on GCP Storage using the Node.js library. Later, I want to access these GCP Storage buckets from my Firebase iOS app. However, I can't. I receive the following error when trying to access my existing GCP buckets from my iOS app:

Your bucket has not been set up properly for Firebase Storage. Please visit https://console.firebase.google.com/project/MY_PROJECT/storage/files to automatically repair this issue and then retry. If the issue lasts longer than five minutes, you may have insufficient permissions to repair the project. You can check your permissions by visiting https://console.firebase.google.com/iam-admin/iam/project?project=MY_PROJECT."

It seems like I need to go to the Firebase Storage console and manually import existing Google Cloud Storage buckets to my Firebase project (as suggested here).

How can I import existing GCP Storage buckets to my iOS Firebase project programmatically? Or, is there a way to access existing GCP buckets and perform operations on them from my iOS app using Firebase Storage library?

Note: I'm on the Blaze plan. [email protected] is added to my existing GCP buckets as Storage admin, just like it is for my default Firebase Storage bucket.

Here's a screenshot from Firebase console that explains the situation. Firebase Screenshot

2
You only have problems when trying to access your GCS buckets, right? No additional issues when trying to access your Firebase Storage buckets? Also, do you use that service account within your code?Kevin Quinzel
I face no issues accessing Firebase Storage buckets. As you mentioned, I face issues accessing GCS buckets. Yesterday I created a GCS bucket using Cloud functions, then manually imported that GCS bucket using the Firebase console following the instructions on the link above. I was able to access my GCS bucket. I do not use that service account within my code. I didn't have use the service account to access my newly created and Firebase accessible GCS bucket.ddeger
So you now can access to your GCS bucket from your app?Kevin Quinzel
I want to access my GCS buckets without having to manually importing them from the Firebase Storage website. I want to import my GCS buckets to Firebase from code. I want to know whether that is possible.ddeger
Please see the attached screenshot above.ddeger

2 Answers

0
votes

I found a doc which talks about The Firebase integration with Google Cloud Platform. It says:

Cloud Storage for Firebase is tightly integrated with Google Cloud Platform. The Firebase SDKs for Cloud Storage store files directly in Google Cloud Storage buckets.

Meaning that there shouldn't be problems when trying to call your GCS buckets from your app. There are a number of ways to access data stored in your Cloud Storage bucket, depending on what you want to do.

For the integration itself, I found this GCS buckets and Firebase Quickstart. Yes, it's mentioned that you need to specify your bucket's location.

It's mentioned that

Read and write access to Storage is restricted so only authenticated users can read or write data

Meaning that you have to implement an authentication process within your app. Check also the Firebase authentication so we can also get rid of the insufficient permissions part.

Hope this is helpful.

EDIT: Maybe I forgot to mention about the Security Rules. After you set them, your app (and your users) will have access to your GCS buckets. I also found a very similar case here.

0
votes

Having encountered the same issue, I'm afraid there is no available programmatic solution right now.

Even if a bucket is created from the Admin SDK in a cloud function, it is not automatically attached to the Firebase project, which is required to apply some security rules and use it on the client side.

The attachment process itself looks like a black box. There is no IAM apparent change after the bucket selection and process validation in the Firebase console.

So, at this date, I would not recommend using custom buckets in Firebase projects for the following reasons:

  • It appears not possible to programmatically attach a custom bucket to a Firebase Project, the only working method being a manual addition via the web console
  • Regarding the very promising admin.securityRules() functions namespace, this is quite new (end of 2019) and the documentation lacks some thorough examples.