gpt4 book ai didi

stormpath - apiKey key ID 和 key 是必需的,即使它们在 express-stormpath 中

转载 作者:行者123 更新时间:2023-12-01 00:39:52 26 4
gpt4 key购买 nike

我正在尝试在 Heroku 应用程序上使用 express-stormpath。我正在关注文档here,我的代码非常简单:

var express = require('express');
var app = express();
var stormpath = require('express-stormpath');

app.use(stormpath.init(app, {
website: true
}));

app.on('stormpath.ready', function() {
app.listen(3000);
});

我已经看过 this question并关注了 Heroku devcenter docs .文档说对于 Heroku 应用程序,没有必要传入选项,但我仍然尝试传入选项,但没有任何效果。例如,我试过这个:
app.use(stormpath.init(app, {
// client: {
// file: './xxx.properties'
// },
client: {
apiKey: {
file: './xxx.properties',
id: process.env.STORMPATH_API_KEY_ID || 'xxx',
secret: process.env.STORMPATH_API_KEY_SECRET || 'xxx'
}
},
application: {
href: 'https://api.stormpath.com/v1/applications/blah'
},
}));

为了尝试看看发生了什么,我在 stormpath-config strategy valdiator 中添加了一个 console.log 行。打印客户端对象,它给了我这个:
{ file: './apiKey-xxx.properties',
id: 'xxx',
secret: 'xxx' }
{ file: null, id: null, secret: null }

Error: API key ID and secret is required.

为什么它被调用两次,第二次,为什么客户端对象的文件、id 和 secret 的值是空值?

当我跑 heroku config | grep STORMPATH ,我得到
STORMPATH_API_KEY_ID:     xxxx
STORMPATH_API_KEY_SECRET: xxxx
STORMPATH_URL: https://api.stormpath.com/v1/applications/[myappurl]

最佳答案

经过无数小时后,我终于通过完全删除附加组件并通过 重新安装它来使其工作。 Heroku CLI 然后导出变量 STORMPATH_CLIENT_APIKEY_IDSTORMPATH_CLIENT_APIKEY_SECRET .出于某种原因,通过 Heroku Dashboard 安装它会导致 express-stormpath 找不到 apiKey 和 secret 字段(即使您导出变量)。

关于stormpath - apiKey key ID 和 key 是必需的,即使它们在 express-stormpath 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38217035/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com