Coder Social home page Coder Social logo

antonybudianto / express-firebase-middleware Goto Github PK

View Code? Open in Web Editor NEW
51.0 5.0 9.0 1.24 MB

:fire: Express middleware for your Firebase applications

License: MIT License

JavaScript 100.00%
express express-middleware firebase firebase-admin firebase-auth middleware

express-firebase-middleware's Introduction

Express Firebase Middleware

Express middleware for your Firebase applications.

npm version

Starting new express firebase project? try out Express Firebase starter

Minimum requirements

  • Node 6 or later
  • npm 3 or later
  • Firebase account

How to use

  1. Install the packages using npm

    npm install express firebase-admin express-firebase-middleware

    Both express and firebase-admin are peerDependencies.

  2. Require it in your express routes

    var firebaseMiddleware = require('express-firebase-middleware');
    
    router.use('/api', firebaseMiddleware.auth);
  3. Now make sure the client's requests have Authorization header like

    Authorization: Bearer <your-client-token>
    

    The client can get the token from their client SDK (Web, Android, iOS Firebase SDK)

  4. When requesting, and token is valid, you can get the user object from response

    router.get('/api/hello', (req, res) => {
        res.json({
            message: `You're logged in as ${res.locals.user.email} with Firebase UID: ${res.locals.user.uid}`
        });
    });

Debug mode

By default, the middleware will log and output to console, you can disable them by setting your environment variable for APP_DEBUG to false

License

MIT

express-firebase-middleware's People

Contributors

antonybudianto avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

express-firebase-middleware's Issues

It alwys return "Unauthorized"?

Hello there, first of all thank you so much for this great middleware.

I followed your guide. but i always get Unauthorized, why?

i am using postman to check. i send request with this header 'Authorization': 'Bearer ASDKFJHASDKFJH5

but still got the same error.

I don't understand this

There needs to be some docs, because i'm completely clueless on what to do after to routers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.