2

I currently develop a realtime kik connector for the unification engine.
To receive the messages, I connect to the websocket endpoint using my users name and password.
Sadly, I get an error 403 everytime.

Is there anything else I have to look out for?

Some examples:

$ curl -XPOST https://apiv2.unificationengine.com/v2/connection/list -u $USER_NAME:$PASSWORD --data "{}" -k -s | jq
{
  "status": 200,
  "info": "200 OK",
  "connections": {
    "kik": {
      "uri": "kik://kik_user@kik.com"
    }
  }
}

Websocket:

$ wscat --auth "$USER_NAME:$PASSWORD" -c wss://apiv2.unificationengine.com/v2/ws/start

error: Error: unexpected server response (403)
boraseoksoon
  • 2,164
  • 1
  • 20
  • 25
Martin
  • 665
  • 1
  • 7
  • 24

1 Answers1

2

Are you using this library? https://github.com/websockets/wscat

Does this library support authentication in this way?

wscat --auth "$USER_NAME:$PASSWORD" -c wss://apiv2.unificationengine.com/v2/ws/start

Done research on this, wscat is using npm ws, https://github.com/websockets/ws for webscoket connection.

Can you try header like this and check

var ws = new WebSocket('wss://apiv2.unificationengine.com/v2/ws/start', {
    origin: 'https://apiv2.unificationengine.com',
    headers: { Authorization: 'base64 auth' }
});

You can create base64 auth like this in nodejs

var auth = "Basic " + new Buffer(USER_ACCESS_KEY + ":" + USER_ACCESS_SECRET).toString("base64");

AMT.in
  • 391
  • 1
  • 5
  • 1
    Ok thanks this solved the problem. It's a little bit strange because `wscat` uses the exactly same code to generate Authorization headers: https://github.com/websockets/wscat/blob/master/bin/wscat#L189 – Martin Oct 18 '16 at 18:22
  • After some more research I now fully understand the problem. The api does not accept calls without the `origin` header. When using `wscat` you have to set the `--origin` option – Martin Oct 26 '16 at 16:22
  • @Martin I am using unification API but getting 403 error. Can u guide me that how to send access token within Curl. – Always_a_learner Jan 06 '17 at 06:12