3

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 Answers1

3

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

rdegges
  • 32,786
  • 20
  • 85
  • 109
  • Now I am getting this error: /node_modules/express-stormpath/node_modules/stormpath/lib/Config.js:57 throw new Error('Unable to read properties file: ' + apiKeyFileName); I am using 2.0.12 version of express-stormpath – user1246197 Oct 22 '15 at 03:36
  • This means your apiKey file path is invalid -- are you sure your file exists and is named `./config/.stormpath/apikey.properties`? Check the spelling / capitalization. – rdegges Oct 23 '15 at 03:51
  • I checked the spelling and capitalization. The file exists. Where can I find docs for the new API version, since there seem to be a lot of changes to stormpath? – user1246197 Oct 23 '15 at 06:12
  • All of our docs are on our website here: http://docs.stormpath.com/nodejs/express/latest/ – rdegges Oct 23 '15 at 13:15
  • So you gave the wrong answer. It should have been apiKey: { id:'', secret:' } – user1246197 Oct 24 '15 at 00:01
  • It works with either apiKey: `{ id: '...', secret: '...' }` OR `apiKey: { file: 'path_to_file' }`. I'm the author of the library =) – rdegges Oct 24 '15 at 03:35
  • Nice! The library is really awesome. The latter option didn't work for me though. – user1246197 Oct 25 '15 at 07:27
  • Hmm, I'll add in some regression tests and make sure that gets resolved if it isn't working for some reason. We do pretty extensive testing on releases, but it's totally possible something fell through the cracks! – rdegges Oct 26 '15 at 16:34