本文介绍了StormPath节点EX preSS Heroku的错误“apiKey.id需要'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个防爆preSS /角使用Stormpath进行身份验证的应用程序。一切工作在我的本地执行,但是当我试图推到它的Heroku与下面的错误崩溃。

错误:

 015-10-07T03:40:29.632276 + 00:00的Heroku [web.1]:开始用命令'过程NPM start`
2015-10-07T03:40:32.269520 + 00:00的应用[web.1]:> cmpe165@1.0.0~~MD~~aux开始/程序
2015-10-07T03:40:32.269497 + 00:00的应用[web.1]:
2015-10-07T03:40:32.269522 + 00:00的应用[web.1]:>节点index.js
2015-10-07T03:40:32.269523 + 00:00的应用[web.1]:
2015-10-07T03:40:34.196981 + 00:00的应用[web.1]:
2015-10-07T03:40:34.197063 + 00:00的应用[web.1]:/app/node_modules/ex$p$pss-stormpath/node_modules/stormpath/lib/authc/RequestAuthenticator.js:8
2015-10-07T03:40:34.197300 + 00:00的应用[web.1]:抛出新的错误('。apiKey.id需要');
2015-10-07T03:40:34.197307 + 00:00的应用[web.1]:^
2015-10-07T03:40:34.199043 + 00:00的应用[web.1]:错误:需要apiKey.id。
 2015-10-07T03:40:34.199047 + 00:00的应用[web.1]:atBasicRequestAuthenticator.RequestAuthenticator(/app/node_modules/ex$p$pss-stormpath/node_modules/stormpath/lib/authc/RequestAuthenticator.js:8 :11)
2015-10-07T03:40:34.199048 + 00:00的应用[web.1]:在新的BasicRequestAuthenticator (/app/node_modules/ex$p$pss-stormpath/node_modules/stormpath/lib/authc/BasicRequestAuthenticator.js:7:36)
2015-10-07T03:40:34.199054 + 00:00的应用[web.1]:在Object.getAuthenticator(/app/node_modules/ex$p$pss-stormpath/node_modules/stormpath/lib/authc/index.js: 27:15)
2015-10-07T03:40:34.199055 + 00:00的应用[web.1]:在新的RequestExecutor(/app/node_modules/ex$p$pss-stormpath/node_modules/stormpath/lib/ds/RequestExecutor.js:26 :37)
2015-10-07T03:40:34.199056 + 00:00的应用[web.1]:在新的数据存储(/app/node_modules/ex$p$pss-stormpath/node_modules/stormpath/lib/ds/DataStore.js:46 :52)
2015-10-07T03:40:34.199058 + 00:00的应用[web.1]:在新的客户端(/app/node_modules/ex$p$pss-stormpath/node_modules/stormpath/lib/Client.js:39:21 )
2015-10-07T03:40:34.199059 + 00:00的应用[web.1]:在initClient(/app/node_modules/ex$p$pss-stormpath/lib/stormpath.js:31:16)
2015-10-07T03:40:34.199061 + 00:00的应用[web.1]:在Object.module.exports.init(/app/node_modules/ex$p$pss-stormpath/lib/stormpath.js:67: 16)
2015-10-07T03:40:34.199062 + 00:00的应用[web.1]:在对象<&匿名GT; (/app/index.js:9:37)
2015-10-07T03:40:34.199063 + 00:00的应用[web.1]:在Module._compile(module.js:456:26)
2015-10-07T03:40:34.220191 + 00:00的应用[web.1]:
2015-10-07T03:40:34.229264 + 00:00的应用[web.1]:NPM ERR! cmpe165@1.0.0~~MD~~aux开始:`节点index.js`
2015-10-07T03:40:34.229476 + 00:00的应用[web.1]:NPM ERR!退出状态8
2015-10-07T03:40:34.229630 + 00:00的应用[web.1]:NPM ERR!
2015-10-07T03:40:34.229727 + 00:00的应用[web.1]:NPM ERR!在cmpe165@1.0.0启动脚本失败。
2015-10-07T03:40:34.230335 + 00:00的应用[web.1]:NPM ERR!这是最有可能与cmpe165包的问题,
2015-10-07T03:40:34.230428 + 00:00的应用[web.1]:NPM ERR!与故宫本身。
2015-10-07T03:40:34.230541 + 00:00的应用[web.1]:NPM ERR!告诉笔者,这种失败在系统上:
2015-10-07T03:40:34.230633 + 00:00的应用[web.1]:NPM ERR!节点index.js
2015-10-07T03:40:34.230846 + 00:00的应用[web.1]:NPM ERR! NPM所有者LS cmpe165
2015-10-07T03:40:34.230758 + 00:00的应用[web.1]:NPM ERR!您可以通过获得他们的信息:
2015-10-07T03:40:34.230939 + 00:00的应用[web.1]:NPM ERR!上面还有可能额外日志输出。
2015-10-07T03:40:34.231109 + 00:00的应用[web.1]:NPM ERR! Linux系统3.13.0-61泛型
2015-10-07T03:40:34.231263 + 00:00的应用[web.1]:NPM ERR!命令/app/.heroku/node/bin/node/app/.heroku/node/bin/npm开始
2015-10-07T03:40:34.231385 + 00:00的应用[web.1]:NPM ERR! CWD /应用
2015-10-07T03:40:34.231508 + 00:00的应用[web.1]:NPM ERR!节点-v v0.10.40
2015-10-07T03:40:34.231632 + 00:00的应用[web.1]:NPM ERR! NPM -v 1.4.28
2015-10-07T03:40:34.231764 + 00:00的应用[web.1]:NPM ERR! code ELIFECYCLE
2015-10-07T03:40:34.234027 + 00:00的应用[web.1]:NPM ERR!
2015-10-07T03:40:34.234774 + 00:00的应用[web.1]:NPM ERR! /应用/ NPM-的debug.log
2015-10-07T03:40:34.234115 + 00:00的应用[web.1]:NPM ERR!其他记录详细信息可以发现:
2015-10-07T03:40:34.234999 + 00:00的应用[web.1]:NPM ERR!不正常code 0
2015-10-07T03:40:35.141609 + 00:00的Heroku [web.1]:进程退出,状态1
2015-10-07T03:40:35.163609 + 00:00的Heroku [web.1]:国家从开始崩溃改变了

防爆preSS服务器:

  VAR前preSS =要求('前preSS');
VAR stormpath =要求('前preSS-stormpath');VAR应用=前preSS();app.use(如press.static(__目录名称+'/公'));
app.use(如press.static(__目录名称+'/控制器'));VAR stormpathMiddleware = stormpath.init(应用程序,{
应用:{
HREF:https://api.stormpath.com/v1/applications/173vkD8p8nkeJb55sXM6WW
 },
 expandCustomData:真实,
 enableForgotPassword:真实,
网址:{
  登录: {
    启用:真实,
    nextUri:__dirname +'/views/jobform.html
  }
}
});app.use(stormpathMiddleware);
app.get(/功能(REQ,RES){
 res.status(200).sendFile(__目录名称+'/views/login.html');
});app.post(/家,功能(REQ,RES){
res.status(200).sendFile(__目录名称+'/views/jobform.html');
});app.get(/工作,功能(REQ,RES){
res.status(200).sendFile(__目录名称+'/views/jobform.html');
})app.get(/创建功能(REQ,RES){
res.status(200).sendFile(__目录名称+'/views/jobform.html');
})//监听传入的请求,并为他们服务。
app.on('stormpath.ready',函数(){
app.listen(process.env.PORT || 9000,函数(){
的console.log(启动服务器...);
});
});


解决方案

看起来你在那里有一些配置错误,我只是固定他们在这里:

  VAR stormpathMiddleware = stormpath.init(应用程序,{
  应用:{
    HREF:https://api.stormpath.com/v1/applications/173vkD8p8nkeJb55sXM6WW
  },
  expandCustomData:真实,
  网站:真实,
  网址:{
    登录: {
      启用:真实,
      nextUri:__dirname +'/views/jobform.html
    }
  },
  客户端:{
    apiKey:{
      ID:'XXX',
      成功秘诀:XXX
    }
  }
});app.use(stormpathMiddleware);app.get(/功能(REQ,RES){
 res.status(200).sendFile(__目录名称+'/views/login.html');
});app.post(/家,功能(REQ,RES){
res.status(200).sendFile(__目录名称+'/views/jobform.html');
});app.get(/工作,功能(REQ,RES){
res.status(200).sendFile(__目录名称+'/views/jobform.html');
})app.get(/创建功能(REQ,RES){
res.status(200).sendFile(__目录名称+'/views/jobform.html');
})//监听传入的请求,并为他们服务。
app.on('stormpath.ready',函数(){
  app.listen(process.env.PORT || 9000,函数(){
  的console.log(启动服务器...);
});

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...");
});
});
解决方案

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...");
});

这篇关于StormPath节点EX preSS Heroku的错误“apiKey.id需要'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 06:38
查看更多