Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 101899

HTTP Post with Tokens

$
0
0

@alonmalka1 wrote:

Hi all,

I trying to implement the new token authentication that was introduced a few versions ago with sending HTTP Post.

I would like to use Python in a different program (Event Ghost) to send the HTTP Post.

I am basicly trying to implement the following:

$ curl -X POST -H “Authorization: Bearer ABCDEFGH”
-H “Content-Type: application/json”
-d ‘{“entity_id”: “switch.christmas_lights”}’
http://localhost:8123/api/services/switch/turn_on

from requests import post

url = ‘http://192.168.1.XX:8123/api/services/switch/turn_on

headers = {‘authorization’: ‘Bearer Token’,‘content-type’: ‘application/json’}

body = {‘entity_id’: ‘switch.fibaro’} <---------------------- What to do with this line??

txt04 = post(url, headers=headers)
print(txt04.text)

Thanks,
Alon

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 101899

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>