PatrickSannes / BetterLogic

A advanced logic library for homey
9 stars 8 forks source link

setting variables thru http #35

Closed llentjes closed 5 years ago

llentjes commented 5 years ago

I use HTTP://HOMEYADDRES/api/app/net.i-dev.betterlogic/VARIABLENAME/VALUE to set some variables within Homey. Since my update to Homey 2 this doesn't work anymore. I get the response: 500 Homey not connected

SailingDuck commented 5 years ago

Can try this: https://github.com/irritanterik/homey-http-request-actions#authorization-on-api-calls Bit tricky to get the bearer, but responded with OK when I tested it with Postman. Can you try this too, from what I heard these bearers are rolling now so not sure if this keeps working. Hope to get more time to look in this more.

dhover commented 5 years ago

I've looked at the headers (with the help of the developer console in Chrome) and I now see that the bearer has changed in Homey 2. The new bearer is in the form: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx If I replace the old bearer with the new one setting of the variables thru http is working again.

llentjes commented 5 years ago

Hi. It may be a stupid question. But how do i find the bearer id?

dhover commented 5 years ago

You can find the bearer by: Start Google Chrome Log into https://developer.athom.com Press F12 Choose the "Network" tab Press F5 to refresh and populate the "Network" tab Press Ctrl-F (search) Typ "bearer" and Press Enter In my case "bearer" is found 3 times The last one is the right one. Look under Tab "Headers", "Request Headers". After the text "authorization: Bearer" you find your bearer code "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

SailingDuck commented 5 years ago

The bearer is indeed a bit harder to find. The procedure is described by dhover and also here: https://github.com/irritanterik/homey-http-request-actions#authorization-on-api-calls