Connect to Firebase buckets - firebase

I have a backend in golang and was wondering how I can connect to Firebase storage to create/delete buckets and add/delete files. Can I use the Admin sdk. I found the client storage lib in golang for google cloud storage. Can I use that? And whats the difference between firebase storage and google cloud storage?

The app I'm working on connects to Firebase Storage Buckets via the Admin SDK, but we're using Firebase Functions in Node.js. However, it looks like the Admin SDK in Go offers the same Storage access, and it's documented (with example code in Go) here:
https://firebase.google.com/docs/storage/admin/start
I like using Admin in Firebase, because you don't have to worry about project configuration and authentication to the various services. Firebase storage is google cloud storage, but with a nice wrapper and well-integrated into other aspects of your Firebase project. You get some limitations as a trade-off for all of that convenience, but unless you run into a feature of Google Cloud that you absolutely need and doesn't exist in Firebase, I'd stick with the Firebase (and Admin) version.

Related

Do I have to enable Firebase if I want to connect to my Cloud Firestore database from outside of Google cloud products?

Till now I was using service account to connect to my Firestore database (Firebase is not enabled) from within Google products like Cloud Functions or Colab.
Now I need to connect to Firestore from html page opened in my browser. Is it possible without enabling Firebase?
Yes, the Google Cloud Firestore NodeJS SDK is meant to be used on server side only. You can use Firebase Web SDK along with Firebase Authentication and Firebase Security Rules to support serverless app architectures where clients connect directly to your Firestore database.
You don't necessarily have to use Firebase Auth. However, it might be a good idea to restrict access and allow only public content to be accessible without authentication.
You can follow the quickstart in the documentation to setup the client SDK.

How to enable Firebase Realtime Database in GCP?

I want to extend an existing GCP project with a Firebase Realtime Database.
According to the Firebase documentation,
all Firebase projects are internally hosted on GCP
it is possible to use Firebase features directly from a GCP project,
so I went to the Marketplace and found the corresponding product page there.
Unlike other product pages, this one doesn't have an "Enable" button on it but rather "Get started for free".
This button does nothing, no response at all. Any deas?
You can just go to the Firebase console and from there you will be able to use Firebase Realtime Database for the same project.
It is not possible to use all the features of Firebase directly on Google Cloud Platform, but you will find common products as Storage and Cloud Functions i.e. that are shared between Firebase and Cloud Platform

How do I access Cloud Firestore when created as a service within Cloud Platform?

I'm familiar with using Cloud Firestore when created through Firebase, but I've created a Cloud Firestore as a service within Cloud Platform and I can't figure out how to have a client access that database. I was expecting there would be someway to generate a GoogleService-Info.plist so that my iOS app can access Firestore.
How is Cloud Firestore different when created from GCP, and how can clients access it?
If you want to access Firestore from iOS, you will still have to go through the Firebase console to add your app to the project and generate that plist file.
What you probably don't realize is that a Firebase project is just like a GCP project. Every Firebase project IS a GCP project, just pre-configured with some services and APIs enabled. Read this blog for a full discussion. If you created your project via the Cloud console, you can just as easily access the very same project from the Firebase console.
Your Firstore instance is 100% the same, no matter how you access it. All the same data and scaling behavior that you expect from Firestore. The only differences lie in how Firebase client apps add special mobile functionality. Read this blog for a full discussion specific to Firestore.
Bottom line is that, for use with mobile apps, you should still use the Firebase console to set that up. You can use both console together at the same time. They show almost entirely the same data, but Firebase is simplified for mobile-centric use.

Could I use GCP infrastructure as a code to setup Firebase Auth, Firestore, RDB, Cloud Functions?

I know that I could setup Cloud Firestore and GCP Cloud Functions with infrastructure as a code, but I'm interested that it will be shown at the Firebase Console. I also can't find any way to deploy Firebase Auth and Realtime database with IaaC.
Any Cloud Functions deployed by either the Firebase CLI or gcloud will appear in both the Firebase console and the Cloud console.
Any data populated in Firestore will also appear in both consoles.
The Cloud console has no view into Firebase Auth or Realtime Database, as those services are unique to Firebase. You will have to use the Firebase console and its tools and SDKs to work with those products.
In fact, a Firebase project is just a Cloud project with extra APIs and services enabled on top. You might be helped by reading this blog series on the relationship between Firebase and Google Cloud.
https://medium.com/google-developers/whats-the-relationship-between-firebase-and-google-cloud-57e268a7ff6f
https://medium.com/google-developers/firebase-google-cloud-whats-different-with-cloud-functions-612d9e1e89cb
https://medium.com/google-developers/firebase-google-cloud-whats-different-with-cloud-firestore-40f1fc3e6d1e
https://medium.com/google-developers/firebase-google-cloud-whats-different-with-cloud-storage-a33fad7c2b80

access google cloud storage with firebase credential

I have a node.js client that uses firebase authentication. Now I want to access Google Cloud Storage, however the firebase SDK for node.js does not include GCS. Using #google-cloud/storage works but only with anonymous access. How do I apply the firebase credential to #google-cloud/storage so that GCS access is in the context of the logged-in user?
Node.js is a server that operates in a privileged environment. The Firebase Admin SDK (aka the Node SDK) talks to other services via a service account.
Firebase Authentication enables client-side authentication. The JavaScript SDK is the client-side SDK.
There is no Node.js client SDK for Firebase that accesses Cloud Storage. Since both the Firebase Admin SDK and the Google Cloud Platform client for Node.js use administrative privileges to access Cloud Storage, it looks like those won't be an option for you either.
The two options I can think of are:
Use the Admin SDK in a Cloud Function, and expose the files from Cloud Storage that way.
Use the REST API for Cloud Storage.
I admit that neither is trivial, so I hope somebody knows a better solution.

Resources