'apiKey.id is required' error thrown when

2019-02-25 06:14发布

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条回答
倾城 Initia
2楼-- · 2019-02-25 06:16

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

查看更多
登录 后发表回答