Nobin Babu
Nobin Babu

Reputation: 23

How do i use JWT in my react js app, if my backend is firebase firestore

can i use JWT in firebase firestore for my react app. If possible how do i use that. I know firebase have firebase auth. But just wanted to use JWT. Please detail.

Upvotes: 0

Views: 535

Answers (1)

Shahid Roofi Khan
Shahid Roofi Khan

Reputation: 1037

React or Angular is totally independent of what authentication you use. Even if you have no authentication they don't care.

To use FireBase JWT auth, you need to,

  1. have a front end login page to collect credentials from user

  2. Firebase will give you Javascript necessary to call firebase from your React application, embed that code. When ever anybody visits your site, make the user put in login credentials

  3. Through those credentials using the javascript library to firebase APIs so you get can get the token if credentials are okay

  4. deny login to enduser if the credentails are not accepted which you can know based on the result of API (invoked using that javascript provided)

  5. if valid token is returned, store it in session storage and use it throughout the application (token itself contains the signature) to verify if the login is legit or not.

Hope this helps

Upvotes: 2

Related Questions