openHAB 3 REST API requires authentication wither through an API Token or, optionally, with Basic Authentication. Milestone 5 is the current version of OH3.
I do not use VS Code with openHAB. Authentication is common with REST APIs though so searching online may help.
If your OH3 is new enough, you can create an API Token from the administration user’s page. You get there by clicking in the bottom left corner of the screen and you will see all session keys too.
Hi,
fist of all thanks for your help. Really appreciated!
@Dynamyte
No difference for me (I had already tried that, but I gave it another go anyway)
@Confectrician
I have tried the correct syntax and I still get the 401 error code
Just to be clear I used the credentials I use to login as an admin into the new home page.
I have also removed the special characters ($) I was using in my password (just in case)
What I have discovered though that the API do not require authorization eg: http://192.168.31.2:8080/rest/
shows all the APIs available
Are you using any kind of reverse proxy in your setup?
I have problems accessing the rest api with this user credential link too, when i open it in browser,
because nginx reverse proxy will reqrite my request.
But doing it with a special api client like postman worked for me with basic auth.
I have tested it especially for you before posting the questions above.
I have one last idea to get the problem sorted out a bit at least.
You could temporary disable the whole authentication for rest api via openHAB console.
When you are able to connect this way with the vscode extension (just host and port configured not user and passsword). We have to start looking at the authentication again.
If there is still errors we have to check again in the extension configuration first.
I am running Openhabian which I installed from scratch yesterday morning on pi Pi4.
It is a standard setup and I have not set any reverse proxy (that I know of).
So as I said earlier I realised that I did not need authorization to access the api, therefore I have deleted Username and Password in the VS Code settings and now I can connect (??)
I have Basic Authentication enabled