错误:没有默认帐户存储映射到指定的应用程序

我按照这里的文档: https : //github.com/stormpath/express-stormpath

错误:没有默认帐户存储映射到指定的应用程序

当我尝试运行我的应用程序时,在控制台中出现上述错误。 这很可能是我的代码的问题,或者我应该去Stormpath网站上的pipe理页面?

我用Windows命令setx设置环境variables,不知道如果我需要这样做,如果我的API密钥和秘密在我的app.js文件。 我为这个问题删除了XXXXXXXX的敏感信息。

var express = require('express'); var app = express(); //Stormpath var stormpath = require('express-stormpath'); //Init Stormpath app.use(stormpath.init(app, { apiKey: {id:'XXXXXXXXXX', secret: 'XXXXXXXXXX'}, secretKey: 'random_string_of_words_go_here', application: 'https://api.stormpath.com/v1/accounts/XXXXXXXXX' })); //home: app.get('/', function(req, res){ res.render('home'); console.log(req.session); }); app.get('/create-quiz', stormpath.loginRequired, function(req, res){ res.render('createQuiz'); }); //404 page: app.use(function(req, res, next){ res.status(404); res.render('404'); }); //500 page: app.use(function(err, req, res, next){ console.error(err.stack); res.status(500); res.render('500'); }); app.on('stormpath.ready', function () { console.log('Stormpath ready...') }); app.listen(app.get('port'), function(){ console.log('Express started on http://localhost: ' + app.get('port') + '; Press ctrl-C to terminate.') }); 

在此先感谢您的帮助。

是的! 这个错误很可能是由于pipe理控制台中的Stormpath应用程序configuration。

每个应用程序都需要一个“目录”来存储你的账户,而且你可能没有这个账户。

尝试loginStormpath并添加一个“目录”以将您的帐户存储在pipe理控制台中。 如果你这样做,请确保检查“默认帐户位置”。

这是我的样子。 希望这可以帮助!

stormpath应用程序页面

(来源:我在Stormpath工作)