@Confectrician you should create a parameter specific for the API token and send it in the X-OPENHAB-TOKEN
HTTP header, it will be accepted too. That way you have the Authorization header free for Basic authorization.
Filed an issue as reminder.
https://github.com/openhab/openhab-vscode/issues/233
We could try this as workaround.
I would like to not invest too much time in this.
Our http lib (request-promise) is deprecated and i would like to replaces that completely,
when working on a proper authentication.
(Best case would be a suitable oauth implementation of course. That should be the long term goal.)
Thank you!
I solved my problem using your hints:
I added a second locaton in my nginx config:
location /rest/ {
proxy_pass http://localhost:8080/rest/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Authorization “Basic base64 encoded name:password”;
}
So VSCode can use the credentials for nginx authentication and nginx send base64 encoded openhab credentials
Not sure how this helped you, but ok
You really shouldn’t do basic auth to authenticate to openHAB though, that’s what the API tokens are for. You create one named “vscode” specifically for VS Code, for example, then you can use it in your NGINX configuration.
Both:
proxy_set_header Authorization “Bearer oh.vscode....”;
and
proxy_set_header X-Openhab-Token “oh.vscode....”;
proxy_set_header Authorization “”;
will work, but in the second case, make sure to remove the original Authorization header that your client sent with the NGINX username & password.
(in fact proxy_set_header Authorization “Basic base64(oh.vscode....:)”;
will work too).
Hi, just found this thread and was able to connect VS Code to my OH3 instance.
Can the rest api with VS Code also be used for rules (UI defined rules that is)? (at the moment the OH plugin only shows items and things)
No we are currently only working with items and things on the api side in the extension.
How would you like to use the rules part of the api in vscode?
Just to get an impression of what would be needed.
Hi Jerome,
Was wondering if its possible, and thinking that if you have access to items and things already, it would be great to have access to rules so that you can use VS Code for rule coding instead of the UI (as was/is possible when you use the files approach).
Not really a big deal though as I am working 90% (besides maps etc.) with the UI for now.
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.