Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "bcrypt-nodejs": "0.0.3",
- "body-parser": "^1.15.1",
- "cors": "^2.7.1",
- "express": "~4.1.1",
- "firebase": "^3.0.3",
- "mongoose": "^4.4.19",
- "oauth2orize": "^1.3.0",
- "passport": "^0.3.2",
- "passport-jwt": "^2.0.0",
- "passport-local": "^1.0.0"
- "jsonwebtoken": "^7.0.0"
- {
- "error": {
- "errors": [
- {
- "domain": "global",
- "reason": "invalid",
- "message": "INVALID_CUSTOM_TOKEN"
- }
- ],
- "code": 400,
- "message": "INVALID_CUSTOM_TOKEN"
- }
- }
- var token = jwt.sign(
- {
- iss: jwt_config.client_email,
- sub: jwt_config.client_email,
- aud: 'https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit',
- iat: iat,
- exp: exp,
- uid: user._id,
- claims: {
- username: user.username,
- user_id: user._id,
- roles: user.role
- }
- },
- jwt_config.private_key,
- {
- algorithm: 'RS256'
- }
- );
- res.json({success: true, token: token});
- var jwt_config = require('../config/Firebase-68824d8xxxxx.json');
- firebase.initializeApp(config);
- $.ajax({
- type: 'post',
- dataType: 'json',
- url: 'http://ec2-52...compute.amazonaws.com:3000/api/authenticate',
- data: $('#loginForm').serialize(),
- complete: function(result) {
- result = result.responseJSON;
- // console.log(JSON.stringify(result, null, 4));
- var success = result.success;
- if (success) {
- var data = result.token;
- firebase.auth().signInWithCustomToken(data).catch(function(error) {
- // Handle Errors here.
- var errorCode = error.code;
- var data = error.message;
- // ...
- });
- } else {
- var data = result.message;
- }
- $('#token').html(data);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement