'apiKey.id is required' error thrown when using express-stormpath with node.js

左心房为你撑大大i 提交于 2019-12-04 04:11:35

问题


I am using express-stormpath with node.js to set up a backend server. This is a snippet of my server.js code where I get an error thrown -

app.use(stormpath.init(app, {
 apiKeyFile: './config/.stormpath/apikey.properties',
 application: '<API_HREF>',
 secretKey: security.stormpath_secret_key
 }));

This is the error -

$ node server.js
../webservices/node_modules/express-    
stormpath/node_modules/stormpath/lib/authc/RequestAuthenticator.js:8
throw new Error('apiKey.id is required.');

How do I fix this?


回答1:


I'm assuming you're using the latest version of the express-stormpath library, which is why you're probably having issues. As of the 2.0.0 release, the library uses new configuration options.

Here's an example of the same thing using the new options:

app.use(stormpath.init(app, {
 client: {
    apiKey: {
      file: './config/.stormpath/apikey.properties'
    }
 },
 application: {
   href: '<API_HREF>',
 }
}));

NOTE: No secretKey is required, as this is generated automatically from your Stormpath API key secret =)

We've made many new changes in the latest library releases that enable all sorts of new, cool stuff! <3



来源:https://stackoverflow.com/questions/33251178/apikey-id-is-required-error-thrown-when-using-express-stormpath-with-node-js

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