Integration of Firebase with Google Cloud Platform (GCP)

Integration of Firebase with Google Cloud Platform (GCP)

tudip-logo

Tudip

16 May 2019

Firebase

Firebase is Google’s mobile application development platform and the fastest way to build your App. Firebase is a complete backend solution that can manage authentication, real-time database and hosting as well. It is built on Google infrastructure and scales automatically.

Firebase-300x169

Why we need Firebase for GCP?

store-data-on-GCP

Steps to Enable Firebase 

  1. Visit – https://console.firebase.google.com/
  2. Click on Add project.
  3. Click on Project name section.
  4. You will see the projects in the dropdown and click on the project.
  5. Accept the Terms and conditions and click on the Create project.
  6. It will redirect you to the firebase home page.

Common infrastructure shared by Firebase and GCP

  1. Products:

    Cloud function and cloud storage are the two products shared by both GCP and Firebase.

  2. Billing:

    Firebase and Cloud products can be placed on the same bill.

  3. Accounts:

    Firebase & GCP both use Google accounts so you can use one google account for both.

  4. Project:

    You can add both GCP product and firebase to a project.

  5. Terms of service:

    Some GCP terms of services are used by firebase products. These are Cloud Storage for Firebase, Cloud Functions for Firebase, Cloud Firestore, and Firebase Test Lab.

Authentication

Firebase supports a lot of different ways to authenticate users.Firebase auth has built in functionality for third party providers such as Facebook, twitter, google.Once user authenticates, information of the user is returned to the device via callbacks. The user information contains a unique id and it is used for identifying the user. Firebase auth also manages the user session so it keeps the user logged in after the application or browser restarts.

Example –

Create a new user with email and password:

firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});

Sign in an existing user with an email address and password:

firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});

Authentication

Cloud Function

Cloud function is a lightweight, event based compute solution that allows you to create small, single-purpose functions that respond to events without the need to manage a server or a runtime environment. You can use Cloud Functions for Firebase if you’re a developer building a mobile app or mobile web app.

Functions

Features

  1. No server management.
  2. Scales automatically.
  3. Run the code in response to events.
  4. Connects and extends services.

What can be built with Cloud Functions

  1. Serverless application backends(eg. Serverless mobile backends, Serverless IoT backends, etc)
  2. Real-time data processing Systems(eg. Real Time stream processing, Event-driven extract, etc)
  3. Intelligent applications(eg. Virtual assistant and chatbots, Video and image analysis, etc)

Cloud Storage

storage

The storage API lets users upload their files to the cloud, so they can be shared with anyone. If you want to set particular rules for sharing files with certain users, you can do this by firebase authentication. All data are transferred over a secure connection and also the transfers with the API are robust. It will automatically resume in case the connection is broken. This is essential for transferring large files over slow or unreliable mobile connections. As the firebase storage is backed by Google cloud storage, it can scale to petabytes. Also, it is available for iOS, Android and web.

Necessary links

  1. https://firebase.google.com/docs/storage/gcp-integration
  2. https://firebase.google.com/

search
Request a quote