Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
var express = require('express')
, request = require('request')
, cors = require('cors')
, FirebaseTokenGenerator = require("firebase-token-generator")
, firebase = require("firebase")
, app = express();

module.exports = function(config) {
var tokenGenerator = new FirebaseTokenGenerator(config.firebase_secrect);


firebase.initializeApp({
//create a private key with https://firebase.google.com/docs/server/setup
serviceAccount: "serviceAccountCredentials.json",
databaseURL: ""
});

app.use(cors());

app.get('/', function(req, res, next){
Expand All @@ -25,8 +30,8 @@ module.exports = function(config) {
given_name: tokenInfo.given_name,
family_name: tokenInfo.family_name
};
var firebaseToken = tokenGenerator.createToken(firebaseTokenInfo);
res.json({valid: true, token: firebaseToken});
var firebaseToken = firebase.auth().createCustomToken(firebaseTokenInfo.uid, firebaseTokenInfo);
res.json({valid: true, token: firebaseToken, user: firebaseTokenInfo});
} else {
res.json({valid: false});
}
Expand All @@ -37,4 +42,4 @@ module.exports = function(config) {
});

return app;
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
"dependencies": {
"cors": "^2.7.1",
"express": "^4.13.3",
"firebase-token-generator": "^2.0.0",
"firebase": "^3.2.1",
"request": "^2.65.0"
},
"main": "index",
"engines": {
"node": ">= 0.4.1"
}

}