user1246197
user1246197

Reputation: 75

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

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?

Upvotes: 3

Views: 2013

Answers (1)

rdegges
rdegges

Reputation: 33824

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

Upvotes: 3

Related Questions