在将express-stormpath与node.js一起使用时引发"apiKey.id是必需的"错误 [英] 'apiKey.id is required' error thrown when using express-stormpath with node.js

查看:97
本文介绍了在将express-stormpath与node.js一起使用时引发"apiKey.id是必需的"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将express-stormpath与node.js一起使用来设置后端服务器.这是我的server.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
 }));

这是错误-

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

我该如何解决?

推荐答案

我假设您使用的是最新版本的 express-stormpath 库,这就是为什么您可能会遇到问题的原因.从2.0.0版本开始,该库使用新的配置选项.

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>',
 }
}));

注意:不需要secretKey,因为它是由您的Stormpath API密钥secret =)自动生成的

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

我们在最新的库发行版中进行了许多新更改,使各种新颖有趣的东西成为可能! < 3

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

这篇关于在将express-stormpath与node.js一起使用时引发"apiKey.id是必需的"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆