Skip to content

BlogOther

Other

Integrate Firebase Authenticate with Loopback

The basic concept of blockchain is quite simple: a distributed database that maintains a continuously growing list of ordered records. However, it is easy to get mixed up as usually when we talk about blockchains we also talk about the problems we are trying to solve with them

2 min read · Estimated time

I. What is Firebase?

Firebase is a platform that will allow you to develop android apps quickly. It offers a number of different services built-in, including some basic analytics.

It includes a lot of helpful services for developers:

  • Authentication
  • Realtime database
  • Storage
  • Hosting

II. How to setup Firebase?

  1. You need to create new project from your Firebase Account
  2. Enable Social Account Integration via Authentication > Sign Method
    1. Facebook: You need to create Facebook Application .Then you need to add the APP ID and APP Private from Facebook Developer
    2. Google
    3. Twitter: You need to create Twitter Application .Then you need to add APP ID and APP Private from Twitter panel.
  3. Download Project Server Configuration
    1. Go to Project Settings > Service Accounts > Admin SDK configuration snippet
    2. Go to Project Settings > Service Accounts > Generate New Private Key

III. Setup Loopback & Firebase Intergration

Install NodeJS Firebase package

npm install --save firebase-admin

From private key in previous step, Let’s save your serviceAccountKey.json into server/serviceAccountKey.json.

Implement your Remote Method handler, the client (mobile or web client) will post into server a request with token that was used from Firebase’s client. Then you can use the token to parse and verify the information with Firebase from server side.

'use strict';
var admin = require('firebase-admin');
var serviceAccount = require('../../server/serviceAccountKey.json');
admin.initializeApp({ type: "service_account", credential:admin.credential.cert(serviceAccount) });
module.exports = function (Account) {
Account.loginFirebase = function(token,callback){
    admin.auth().verifyIdToken(token).then(function (decodedToken) {
    console.log(decodedToken); // Your logic here });
    }
}

Then everything was finished, you can use decoded

Token to parse email and account information with your logic.

More insights from Zodinet

START WITH ZODINET

Need similar software built?

Tell us about your problem. Zodinet sends a first quote within 2 days.

Explore Zodinet

VIEN

Services

Choose the right way to deliver

See all services

Let's get started

Tell Zodinet about your problem.

Choose the way that suits you.

Send a consultation request

Contents

Jump to the part you need

  1. I. What is Firebase?
  2. II. How to setup Firebase?
  3. III. Setup Loopback & Firebase Intergration