与Jazz RTC的身份验证失败

时间:2018-11-30 10:00:38

标签: node.js ibm-jazz

我正在尝试使用Jazz rtc api登录,但我总是得到302 FOUND

当然,我正在将Java项目转换为Nodejs。在Java上,身份验证可与此完美配合:

HttpPost postFormRequest = new HttpPost(host + "/auth/j_security_check");
List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>();
nvps.add(new BasicNameValuePair("j_username", rtcLogin));
nvps.add(new BasicNameValuePair("j_password", rtcPassword));
postFormRequest.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));
HttpResponse postFormResponse = client.execute(postFormRequest);

现在在Nodejs中,我正在尝试:

const host = 'https://host.com/ccm';
const rtcAuthPath = '/auth/j_security_check';
const credentials = { j_username: 'login', j_password: '********' };
const authOptions = {
    url: host + rtcAuthPath,
    body: JSON.stringify(credentials)
};

function auth(error, response, body){
    log(response);
}

request.post(authOptions, auth);

这两段代码似乎做同样的事情,但只有Java代码有效。

Nodejs中的代码有什么问题?

请注意,host在Java和nodejs中具有相同的值

0 个答案:

没有答案