AngularFire with token authentication on Node backend server
- Run these commands to add the project locally:
$ git clone https://github.com/LukeSchlangen/nodeFire
$ cd nodeFire
$ npm install
-
Create a free Firebase account at https://firebase.google.com
-
Create a project from your Firebase account console
-
Add a connection to firebase on your front end
-
Click the “Add Firebase to your web app” icon
-
Copy the contents WITHOUT SCRIPT TAGS or the CDN from the resulting popup into
public/config.js
. It should look like this:
```javascript
// Initialize Firebase
var config = {
apiKey: "XXXXXXXXXXXXXXXXXXXXXX",
authDomain: "XXXXXXXXXXXX.firebaseapp.com",
databaseURL: "https://XXXXXXXXXXXX.firebaseio.com",
storageBucket: "XXXXXXXXXXXX.appspot.com",
messagingSenderId: "XXXXXXXXXX"
};
firebase.initializeApp(config);
```
- Add a firebase service account to you node project
- Navigate to the Service Accounts tab in your project's settings page.
- Select your Firebase project.
- Copy your
databaseURL
from theAdmin SDK configuration snippet
. The line you need will look like this:databaseURL: "https://XXXXXXXXX.firebaseio.com"
. - Navigate to the
server/modules/decoder.js
file in the node project and replace the databaseURL. Only replace that line. It is inside of theadmin.initializeApp
:
```javascript
admin.initializeApp({
credential: admin.credential.cert("./server/firebase-service-account.json"),
databaseURL: "https://XXXXXXXXX.firebaseio.com" // replace this line with your URL
});
```
-
Return to firebase Service Accounts. Navigate to your project again if you have left it.
-
Click the Generate New Private Key button at the bottom of the Firebase Admin SDK section of the Service Accounts tab.
-
Rename the new JSON file to
firebase-service-account.json
and save it in theserver
folder of your application. -
Return to Firebase console. Configure Google as an authentication provider for your Firebase project.
-
In the Firebase console for your project (you may already be there from the previous step), click "Authentication" in left panel
-
Click "Set Up Sign-In Method" button
-
Select "Google"
-
Click the "edit" icon
-
Toggle Google to
on
-
Run
npm start
to run your application onlocalhost:5000
##Contributing
- The repository is open to contribution from all interested developers. Kindly send us Pull Requests with explanation as to what changes you have done.
- Also, you can write to us by opening an Issue and also solve a current issue if possible.
##License
- The software is registered under the MIT License