0
我有一个简单的NodeJS应用程序,它可以使用远程Java CMS进行身份验证。成功验证后,CMS会返回一个cookie。我无法访问NodeJS中的http post后返回的cookie
但是,对于我的生活,我无法想象如何访问/获取此cookie值。 (我需要cookie才能向CMS的API发送请求,一旦通过验证)。
我得到的cookie在curl命令中返回ok,但无法在NodeJS中访问它。 curl命令:
curl -v -k --data "username=admin&password=password111&realm=cms101"
https://test.abeo.ie/gatekeeper/rs/authenticate/login
现在,这里是我的NodeJS应用程序的代码:
//disable self-signed ssl cert rejection
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
var http = require('http');
var request = require('request');
var Cookies = require('cookies');
//enable cookies
request.defaults({jar: true});
request({
url: 'https://test.abeo.ie/gatekeeper/rs/authenticate/login', //URL to hit
qs: {username: 'admin', password: 'password111', realm: 'cms101'}, //Query string data
method: 'POST', //Specify the method
headers: { //We can define headers too
'Content-Type': 'application/x-www-form-urlencoded'
}
},
function(error, response, body){
if(error) {
console.log(error);
} else {
//response.cookie comes out as 'undefined'
console.log(response.statusCode, body, response.cookie);
}
})
所以我的问题是:如何从响应为是Response.Cookie值打印出来作为读取cookie值未定义。
感谢,
迈克
**如果这个问题似乎模糊......只是这样说,我将它清除掉。