无法使用Atlassian-crowd-client软件包对人群进行身份验证

时间:2018-04-11 06:24:20

标签: json authentication sails.js atlassian-crowd

我正在使用sails.js和Atlassian-crowd-client软件包在人群中进行身份验证。但它返回错误:Error: Invalid Response from Crowd, expecting JSON. 这是我的代码,我不知道问题出在哪里。如果有人帮忙,我会感激不尽。

var atlassianCrowdClient = require('atlassian-crowd-client');
var crowd = new atlassianCrowdClient({
  baseUrl: 'http://my-host/crowd/console/login.action',
  application: {
    name: 'app-name',
    password: 'app-password'
  },
  "Content-Type":"application/json",
  "Accept": "application/json"
});

module.exports = {            
  show: function (req, res) {crowd.session.create({'username':'my-username','password':'my-password'})
    .then(function (session) {
      console.log('Crowd SSO token is ' + session.token);
    })
    .catch(function(err) {
        console.log('err: ' + err)
    })

  }

};

1 个答案:

答案 0 :(得分:0)

我认为您使用的baseURL是错误的。它应该是

baseUrl: 'https://crowd.example.com/'

见这里: https://www.npmjs.com/package/atlassian-crowd-client