does anyone have experience or examples of how to use the http binding in combination with session IDs.
I want to connect to a server with the http binding but for security reasons the serves doesn’t accept the usual username/password structure. It forces https and it forces the use of session IDs. So you authenticated with username and password, then you get a session ID back from the server and you use this session ID is all following requests.
I’m looking for examples on how to use the http binding to connect to such server.
The HTTP binding really isn’t setup to do this. You could probably make something work using the HTTP actions in rules. for example, create a rule to:
log in and get the token
make one or more HTTP requests using that token
log out
I’ve done similar things in Python but this approach should work in Rules as well, so long as you are able to actually format the HTTP GETS, PUTS, and POSTS the way the API needs it.
Beyond that, you can implement the above in a script using curl and call that script using the Exec binding or executeCommandLine actions.
Finally, you could implement a new binding for the API you are interacting with. If it is a common and/or popular API I bet there would be some demand for it.
Rich thanks a lot, that’s what I was thinking as well. Might either do your suggestion login every time or login once keep using session ID till I get message session no longer valid and login again.
I have done it in php (see below just FYI the part to authenticate and to read the temperature with obtained session ID)
so will try putting it in rules and worst case exec the script. But it still isn’t a really nice and clear solution.
Rich I would love to build a binding but that won’t be for the next months I’m afraid. Problem is I never used java before (only perl and php) and am new to Openhab as well. So have some learning curve to go through. So will first get my Openhab up and running, build it on rules and afterwards dive into binding development.
The funny thing is this is actually to get functionality of a binding that existed before and for some reason was deleted (binding for Siemens webserver). So if only I could compile the source files to a jar file that would give a much cleaner solution than I will ever be able to build.
Issue solved, discovered my transform services were not working, installing them, updating the addons.dfg and an update/upgrade eventually did the trick