-
Notifications
You must be signed in to change notification settings - Fork 2
How to
Augusto Crespo edited this page Jul 8, 2021
·
4 revisions
The main goal of this document is to provide developer a tutorial of how to configure some parts of the site.
- A Firebase project created with Google sign-in method activated
- Firebase installed in the project
-
Create a firebase.js file
- Import Firebase and firebase auth module
- Create the const firebaseConfigu with all credentials required in your project: apiKey, authDomain, projectId, etc.
- Initialize firebase and create the var provider:
firebase.initializeApp(firebaseConfig); var provider = new firebase.auth.GoogleAuthProvider();
- Export firebase and provider
-
In Vue component
- Import the firebase.js file created before
- Create a method signInWithPopup calling the function
firebase .auth() .signInWithPopup(provider) .then((result) => { this.credential = result.credential; // This gives you a Google Access Token. You can use it to access the Google API. this.token = this.credential.accessToken; // The signed-in user info. this.user = result.user; }) .catch((error) => { // Handle Errors here. });
In order to create user roles such as "admin", Firebase does not support this directly, but it allows to set custom user claims. We managed this through backend. More info at: https://dev.to/emeka/securing-your-express-node-js-api-with-firebase-auth-4b5f