Logic Machine Forum
Remote service without basic auth - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: Remote service without basic auth (/showthread.php?tid=5532)



Remote service without basic auth - Andrea Becagli - 25.07.2024

I am trying to use Remote services with an LM with 20240426 firmware but since there is no more basic auth, it does not work and always asks to login (if I use get request through browser). Is there a solution? Do I need to add some body to the request maybe?


RE: Remote service without basic auth - admin - 25.07.2024

Working example using Fetch API:

Code:
async function send() {
  var url = 'http://192.168.0.9/scada-remote?m=json&r=grp&fn=write&alias=0/0/1&value=1'
  var user = 'remote'
  var pass = 'Remote123'
  var headers = new Headers()

  headers.append('Authorization', 'Basic ' + btoa(`${user}:${pass}`))

  var res = await fetch(url, { method: 'GET', headers: headers })

  console.log(res)
}



RE: Remote service without basic auth - Andrea Becagli - 27.07.2024

Ok, that could be a problem since I am trying to exchange info with Yealink phones, which can not make requests with headers. Is there a way I can make API calls without a header?


RE: Remote service without basic auth - admin - 29.07.2024

You can create a .lp script instead: https://kb.logicmachine.net/misc/apps/#lp-scripts
It does not require authentication if placed in the public directory.


RE: Remote service without basic auth - Andrea Becagli - 05.08.2024

(29.07.2024, 06:25)admin Wrote: You can create a .lp script instead: https://kb.logicmachine.net/misc/apps/#lp-scripts
It does not require authentication if placed in the public directory.

Interesting, could you give me an example of a script like this?


RE: Remote service without basic auth - admin - 06.08.2024

Check this: https://forum.logicmachine.net/showthread.php?tid=3141&pid=20407#pid20407
The example above can be placed in user directory so only authorized users can access it.