我是新的Node js,我想用Azure Active Directory进行身份验证。我下载节点,并安装NPM作为后提到Here活动目录集成问题Nodejs
npm install express
npm install ejs
npm install ejs-locals
npm install restify
npm install mongoose
npm install bunyan
npm install assert-plus
npm install passport
npm install passport-azure-ad
为每个文档,我也跟着第3步:设置您的应用程序使用的护照节点-JS战略
这里是配置.js
exports.creds = {
returnURL: 'https://hpe.onmicrosoft.com/8d332647-xxxx-4xxc-8xx-11776XXXXX',
identityMetadata: 'https://login.microsoftonline.com', // For using Microsoft you should never need to change this.
clientID: '22XXXX9-b5fa-XXXXb-bc7a-XXXXXXXa92a',
clientSecret: 'Srekv8dM1NqP4Sqnxxxxxxxxxxxx', // if you are doing code or id_token code
skipUserProfile: true, // for AzureAD should be set to true.
responseType: 'id_token code', // for login only flows use id_token. For accessing resources use `id_token code`
responseMode: 'query', // For login only flows we should have token passed back to us in a POST
//scope: ['email', 'profile'] // additional scopes you may wish to pass
};
和其余的代码我已经写在文档中提到的。
但是,当我运行app.js得到问题。
C:\Nikunj Data\Project\Active Directory\WebApp-OpenIDConnect-NodeJS-skeleton\node_modules\passport-azure-ad\lib\validator.js:51
throw new TypeError(`Invalid value for ${item}.${checker.error}`);
^
TypeError: Invalid value for redirectUrl.The URL must be valid and be https://
at Object.keys.forEach (C:\Nikunj Data\Project\Active Directory\WebApp-OpenIDConnect-NodeJS-skeleton\node_modules\passport-azure-ad\lib\validator.js:51:13)
at Array.forEach (native)
at Validator.validate (C:\Nikunj Data\Project\Active Directory\WebApp-OpenIDConnect-NodeJS-skeleton\node_modules\passport-azure-ad\lib\validator.js:37:28)
at new Strategy (C:\Nikunj Data\Project\Active Directory\WebApp-OpenIDConnect-NodeJS-skeleton\node_modules\passport-azure-ad\lib\oidcstrategy.js:495:13)
at Object.<anonymous> (C:\Nikunj Data\Project\Active Directory\WebApp-OpenIDConnect-NodeJS-skeleton\app.js:42:14)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
请帮助我..
问候 Nikunj
尝试1: 我试过难遇的推荐代码,我得到了错误:
(node:2628) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
events.js:182
throw er; // Unhandled 'error' event
^
MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]
at Pool.<anonymous> (C:\Nikunj Data\Project\Active Directory\WebApp-OpenIDConnect-NodeJS-master\node_modules\mongodb\node_modules\mongodb-core\lib\topologies\server.js:329:35)
at emitOne (events.js:115:13)
at Pool.emit (events.js:210:7)
at Connection.<anonymous> (C:\Nikunj Data\Project\Active Directory\WebApp-OpenIDConnect-NodeJS-master\node_modules\mongodb\node_modules\mongodb-core\lib\connection\pool.js:280:12)
at Object.onceWrapper (events.js:318:30)
at emitTwo (events.js:125:13)
at Connection.emit (events.js:213:7)
at Socket.<anonymous> (C:\Nikunj Data\Project\Active Directory\WebApp-OpenIDConnect-NodeJS-master\node_modules\mongodb\node_modules\mongodb-core\lib\connection\connection.js:187:49)
at Object.onceWrapper (events.js:316:30)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at emitErrorNT (internal/streams/destroy.js:62:8)
at _combinedTickCallback (internal/process/next_tick.js:102:11)
at process._tickCallback (internal/process/next_tick.js:161:9)
(节点:2628)DeprecationWarning:'打开()'在猫鼬> = 4.11.0已过时,可使用'openUri()'代替,或者如果使用'连接(设定'useMongoClient'选项)'或'createConnection()'。请参阅http://mongoosejs.com/docs/connections.html#use-mongo-client events.js:182 throw er; //未处理'错误'事件 ^ MongoError:在第一次连接[MongoError:连接ECONNREFUSED 127.0.0.1:27017] 时,无法连接到服务器[localhost:27017]。(C:\ Nikunj Data \ Project \ Active ...................... –
下载后出现此错误并尝试此代码 –
要进行测试,请设置出口如果你想使用默认的会话存储进行快速会话,请使用config.js中的useMongoDBSessionStore –