StormPath Node Express Heroku Error 'apiKey.id is required'

丶灬走出姿态 提交于 2019-12-13 18:04:41

问题


I have an Express/Angular app using Stormpath for authentication. Everything works on my local implementation but when I attempt to push to Heroku it crashes with the error below.

Error:

"015-10-07T03:40:29.632276+00:00 heroku[web.1]: Starting process with command `npm start`
2015-10-07T03:40:32.269520+00:00 app[web.1]: > cmpe165@1.0.0 start /app
2015-10-07T03:40:32.269497+00:00 app[web.1]:
2015-10-07T03:40:32.269522+00:00 app[web.1]: > node index.js
2015-10-07T03:40:32.269523+00:00 app[web.1]:
2015-10-07T03:40:34.196981+00:00 app[web.1]:
2015-10-07T03:40:34.197063+00:00 app[web.1]: /app/node_modules/express-stormpath/node_modules/stormpath/lib/authc/RequestAuthenticator.js:8
2015-10-07T03:40:34.197300+00:00 app[web.1]:     throw new   Error('apiKey.id is required.');
2015-10-07T03:40:34.197307+00:00 app[web.1]:           ^
2015-10-07T03:40:34.199043+00:00 app[web.1]: Error: apiKey.id is   required.
 2015-10-07T03:40:34.199047+00:00 app[web.1]: atBasicRequestAuthenticator.RequestAuthenticator     (/app/node_modules/express-stormpath/node_modules/stormpath/lib/authc/RequestAuthenticator.js:8:11)
2015-10-07T03:40:34.199048+00:00 app[web.1]:     at new BasicRequestAuthenticator (/app/node_modules/express-stormpath/node_modules/stormpath/lib/authc/BasicRequestAuthenticator.js:7:36)
2015-10-07T03:40:34.199054+00:00 app[web.1]:     at Object.getAuthenticator (/app/node_modules/express-stormpath/node_modules/stormpath/lib/authc/index.js:27:15)
2015-10-07T03:40:34.199055+00:00 app[web.1]:     at new RequestExecutor (/app/node_modules/express-stormpath/node_modules/stormpath/lib/ds/RequestExecutor.js:26:37)
2015-10-07T03:40:34.199056+00:00 app[web.1]:     at new DataStore (/app/node_modules/express-stormpath/node_modules/stormpath/lib/ds/DataStore.js:46:52)
2015-10-07T03:40:34.199058+00:00 app[web.1]:     at new Client (/app/node_modules/express-stormpath/node_modules/stormpath/lib/Client.js:39:21)
2015-10-07T03:40:34.199059+00:00 app[web.1]:     at initClient (/app/node_modules/express-stormpath/lib/stormpath.js:31:16)
2015-10-07T03:40:34.199061+00:00 app[web.1]:     at Object.module.exports.init (/app/node_modules/express-stormpath/lib/stormpath.js:67:16)
2015-10-07T03:40:34.199062+00:00 app[web.1]:     at Object.<anonymous> (/app/index.js:9:37)
2015-10-07T03:40:34.199063+00:00 app[web.1]:     at Module._compile (module.js:456:26)
2015-10-07T03:40:34.220191+00:00 app[web.1]:
2015-10-07T03:40:34.229264+00:00 app[web.1]: npm ERR! cmpe165@1.0.0 start: `node index.js`
2015-10-07T03:40:34.229476+00:00 app[web.1]: npm ERR! Exit status 8
2015-10-07T03:40:34.229630+00:00 app[web.1]: npm ERR!
2015-10-07T03:40:34.229727+00:00 app[web.1]: npm ERR! Failed at the cmpe165@1.0.0 start script.
2015-10-07T03:40:34.230335+00:00 app[web.1]: npm ERR! This is most likely a problem with the cmpe165 package,
2015-10-07T03:40:34.230428+00:00 app[web.1]: npm ERR! not with npm itself.
2015-10-07T03:40:34.230541+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2015-10-07T03:40:34.230633+00:00 app[web.1]: npm ERR!     node index.js
2015-10-07T03:40:34.230846+00:00 app[web.1]: npm ERR!     npm owner ls cmpe165
2015-10-07T03:40:34.230758+00:00 app[web.1]: npm ERR! You can get their info via:
2015-10-07T03:40:34.230939+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2015-10-07T03:40:34.231109+00:00 app[web.1]: npm ERR! System Linux 3.13.0-61-generic
2015-10-07T03:40:34.231263+00:00 app[web.1]: npm ERR! command "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2015-10-07T03:40:34.231385+00:00 app[web.1]: npm ERR! cwd /app
2015-10-07T03:40:34.231508+00:00 app[web.1]: npm ERR! node -v    v0.10.40
2015-10-07T03:40:34.231632+00:00 app[web.1]: npm ERR! npm -v 1.4.28
2015-10-07T03:40:34.231764+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2015-10-07T03:40:34.234027+00:00 app[web.1]: npm ERR!
2015-10-07T03:40:34.234774+00:00 app[web.1]: npm ERR!     /app/npm- debug.log
2015-10-07T03:40:34.234115+00:00 app[web.1]: npm ERR! Additional logging details can be found in:
2015-10-07T03:40:34.234999+00:00 app[web.1]: npm ERR! not ok code 0
2015-10-07T03:40:35.141609+00:00 heroku[web.1]: Process exited with status 1
2015-10-07T03:40:35.163609+00:00 heroku[web.1]: State changed from starting to crashed"

Express Server:

var express = require('express');
var stormpath = require('express-stormpath');

var app = express();

app.use(express.static(__dirname + '/public'));
app.use(express.static(__dirname + '/controllers'));

var stormpathMiddleware = stormpath.init(app, {
application: {
href: 'https://api.stormpath.com/v1/applications/173vkD8p8nkeJb55sXM6WW'
 },
 expandCustomData: true,
 enableForgotPassword: true,
website: {
  login: {
    enabled: true,
    nextUri: __dirname + '/views/jobform.html'
  }
}
});

app.use(stormpathMiddleware);


app.get("/", function(req,res){
 res.status(200).sendFile(__dirname + '/views/login.html');
});

app.post("/home", function(req,res){
res.status(200).sendFile(__dirname + '/views/jobform.html');
});

app.get("/jobs", function(req,res){
res.status(200).sendFile(__dirname + '/views/jobform.html');
})

app.get("/create", function(req,res){
res.status(200).sendFile(__dirname + '/views/jobform.html');
})

// Listen for incoming requests and serve them.
app.on('stormpath.ready', function() {
app.listen(process.env.PORT || 9000, function() {
console.log("Starting server...");
});
});

回答1:


It looks like you have some config errors in there, I just fixed them here:

var stormpathMiddleware = stormpath.init(app, {
  application: {
    href: 'https://api.stormpath.com/v1/applications/173vkD8p8nkeJb55sXM6WW'
  },
  expandCustomData: true,
  website: true,
  web: {
    login: {
      enabled: true,
      nextUri: __dirname + '/views/jobform.html'
    }
  },
  client: {
    apiKey: {
      id: 'xxx',
      secret: 'xxx'
    }
  }
});

app.use(stormpathMiddleware);

app.get("/", function(req,res) {
 res.status(200).sendFile(__dirname + '/views/login.html');
});

app.post("/home", function(req,res){
res.status(200).sendFile(__dirname + '/views/jobform.html');
});

app.get("/jobs", function(req,res){
res.status(200).sendFile(__dirname + '/views/jobform.html');
})

app.get("/create", function(req,res){
res.status(200).sendFile(__dirname + '/views/jobform.html');
})

// Listen for incoming requests and serve them.
app.on('stormpath.ready', function() {
  app.listen(process.env.PORT || 9000, function() {
  console.log("Starting server...");
});


来源:https://stackoverflow.com/questions/32983531/stormpath-node-express-heroku-error-apikey-id-is-required

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!