Picture of Uros 1135
Registered 11 years 358 days
Uros 1135 Wednesday, 9 June 2021, 08:04 AM
Auth login to app via websocket
@Customer Softnet
@Support Softnet


Dear

I am trying to get auth working for websocket to be able to retrive session and key and then getting csv data for calls.

From your wiki login should be like that (url: ws://PBX_IP/PBX0/APPS/websocket).

{
"app": "reporting",
"digest": "a205299ed2ef2786c311e0be1b14db343f2cadd906a6ae7b564eee34bda5e9a1",
"dn": "",
"domain": "",
"guid": "",
"mt": "AppLogin",
"sip": ""
}

The poing here for me i guss is how to calculate digest.
From your wiki it should be: SHA256

and it should be calculated like:
<app>:<domain>:<sip>:<guid>:<dn>:<challenge>:<password>
reporting:softnet:::challenge:pwd (is this right or should be anything alse here? do i need info?)

challenge i get from { "mt": "AppChallenge" }
pwd is password for pbx (what about userpart, is not needed?)


Problem is that I am always getting false. Can you help me if I do right SHA256 calculation for reporting or missing something? I can see from console log in www that myapps is connecting to websocket url like: wss://app.innovaphone.softnet.si/softnet/reporting/132852


So which url is correct to use? If I use wss://app.innovaphone.softnet.si/softnet/reporting/132852 and do AppLogin socket connecton is closed. For ip to PBX i get back false (ws://PBX_IP/PBX0/APPS/websocket).

ust maybe this from logs:


06-04 07:30:34.396 reporting@softnet IWebsocket(connection id: 61325)::SocketRecvResult(): Received Websocket message WS_WEBSOCKET_RECV_RESULT (fragmented: false, text: true, data size: 167)
06-04 07:30:34.396 00F98380 - 7B 0A 20 20 20 20 22 61 70 70 22 3A 20 22 69 6E {. "app": "in
06-04 07:30:34.396 00F98390 - 6E 6F 76 61 70 68 6F 6E 65 2D 72 65 70 6F 72 74 novaphone-report
06-04 07:30:34.396 00F983A0 - 69 6E 67 22 2C 0A 20 20 20 20 22 64 69 67 65 73 ing",. "diges
06-04 07:30:34.396 00F983B0 - 74 22 3A 20 22 61 32 30 35 32 39 39 65 64 32 65 t": "a205299ed2e
06-04 07:30:34.396 00F983C0 - 66 32 37 38 36 63 33 31 31 65 30 62 65 31 62 31 f2786c311e0be1b1
06-04 07:30:34.396 00F983D0 - 34 64 62 33 34 33 66 32 63 61 64 64 39 30 36 61 4db343f2cadd906a
06-04 07:30:34.396 00F983E0 - 36 61 65 37 62 35 36 34 65 65 65 33 34 62 64 61 6ae7b564eee34bda
06-04 07:30:34.396 00F983F0 - 35 65 39 61 31 22 2C 0A 20 20 20 20 22 64 6F 6D 5e9a1",. "dom
06-04 07:30:34.396 00F98400 - 61 69 6E 22 3A 20 22 73 6F 66 74 6E 65 74 22 2C ain": "softnet",
06-04 07:30:34.396 00F98410 - 0A 20 20 20 20 22 6D 74 22 3A 20 22 41 70 70 4C . "mt": "AppL
06-04 07:30:34.396 00F98420 - 6F 67 69 6E 22 0A 7D ogin".}
06-04 07:30:34.396 reporting@softnet WebserverWebsocketHandler(00fb06a0,00fc85f0,61325)::Send buffer:0xd5297e10 len:53 text:TRUE
06-04 07:30:34.396 D5297E10 - 7B 22 6D 74 22 3A 22 41 70 70 4C 6F 67 69 6E 52 {"mt":"AppLoginR
06-04 07:30:34.396 D5297E20 - 65 73 75 6C 74 22 2C 22 61 70 70 22 3A 22 69 6E esult","app":"in
06-04 07:30:34.396 D5297E30 - 6E 6F 76 61 70 68 6F 6E 65 2D 72 65 70 6F 72 74 novaphone-report
06-04 07:30:34.396 D5297E40 - 69 6E 67 22 7D ing"}
06-04 07:30:34.396 reporting@softnet WebserverMessage(connection id: 59608)::WebsocketSend: Sending Websocket message WS_WEBSOCKET_SEND (fragmented: false, text: true, sdata ize: 53)
06-04 07:30:34.396 D5297E10 - 7B 22 6D 74 22 3A 22 41 70 70 4C 6F 67 69 6E 52 {"mt":"AppLoginR
06-04 07:30:34.396 D5297E20 - 65 73 75 6C 74 22 2C 22 61 70 70 22 3A 22 69 6E esult","app":"in
06-04 07:30:34.396 D5297E30 - 6E 6F 76 61 70 68 6F 6E 65 2D 72 65 70 6F 72 74 novaphone-report
06-04 07:30:34.396 D5297E40 - 69 6E 67 22 7D ing"}
06-04 07:30:34.396 reporting@softnet AppWebsocket(00fc85f0)::Error
06-04 07:30:34.396 reporting@softnet WebserverWebsocketHandler(00fb06a0,00fc85f0,61325)::Close


thank you for all help!
Uros
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Wednesday, 9 June 2021, 01:10 PM
Re: Auth login to app via websocket
Hi Uros,

if you need to login to your Reporting instance to retrieve CSV files, you must login with websocket to wss://app.innovaphone.softnet.si/softnet/reporting (the build number doesn't matter).

The password must be the password of your reporting instance.
During a standard install scenario, a random password is generated, so you have no knowledge of this password.
You could now set an own password on the reporting instance and configure this password in the Reporting app objects (reporting, calllist, calllistapi), but I wouldn't recommend this method as this password must be maintained on two different sides (PBX and reporting instance in the AP Manager).

Instead we have a Services API where you can retrieve a login for a specific App:
https://sdk.innovaphone.com/doc/appwebsocket/Services.htm#GetServiceLogin

Configuration:
  • create a new App object inside your PBX (the name and password is up to you)
  • tick the Services checkmark under Apps to allow access to the Services API
  • tick the reporting checkmark under App to allow access to reporting
Login flow:
  • establish an AppWebsocket connection to your own App object (URL is wss://pbx_ip/PBX0/APPS/websocket)
  • after a successfull AppLoginResult, establish a second AppWebsocket connection to the Reporting service (URL wss://app.innovaphone.softnet.si/softnet/reporting), but just send the initial AppChallenge to retrieve a challenge
  • with this challenge, trigger the GetServiceLogin message on your first websocket connection, wait for GetServiceLoginResult and use the received properties to send the AppLogin on your second connection to the Reporting (you basically get the digest which you simply need to forward in the second AppLogin together with all the other parameters and don't forget the info property, as this is calculated within the digest too) (the properties key and salt can be ignored for your purpose)
  • after a successfull login on this second connection, you can follow the description in the reporting wiki to retrieve a key which can be used inside the final GET request
Greetings,
Daniel
← You can define your color theme preference here