How would one authenticate and hit a HTTPS URL from LUA? In particular to get the resultant response back from the server?
Background: Basically want to use the Pushbullet API API. I can see how to use it in curl, however I want to use it within LUA, and really want to get the responses back to see them.
I’ve got to this point but getting a 401 response header (unauthorized) - are there any obvious issues with my code/syntax below? (I’ve changed the access token) API reference for pushbullet is here: Pushbullet API
I’ll have to take it on your honour that you’ve built the access token properly: join the username, a literal colon, and the password into a single string, then pass it through mime.b64().
Update - Actually heard back from Chris at pushbullet which was great. He noted Basic auth was a bit more complicated (guessing I may have needed to do the 2 step process), however that “We also allow Bearer auth”.
So in summary changing my code with the following line made things work:
[quote=“mixedup, post:5, topic:184588”]thanks for the info
Update - Actually heard back from Chris at pushbullet which was great. He noted Basic auth was a bit more complicated (guessing I may have needed to do the 2 step process), however that “We also allow Bearer auth”.
So in summary changing my code with the following line made things work:
Thanks for your work, I’ve been looking for a way to send notifications to Pushbullet for quite some time, and with this code it worked! I don’t know if you are capable of doing it, but maybe you can turn this in to a plugin for Vera?
I recently added a function to the Lua Startup to use for sending pushes via PushBullet, this also includes a url_encode function to make URL’s work properly. Currently the device identity is hard coded but it could be added as a parameter. Happy to provide the code if anyone wants to use it.