andypnz
(Andrew Palmer)
April 13, 2023, 12:15am
1
Hi. I am trying to pull some HA sensor data to display on a website. I am having difficulty accessing the HA API.
Can I do this using my Nabu Casa url? https://xxxxxxxxxxx.ui.nabu.casa/api does not work. The response is ‘unaurthorized’… how do I gain authorization? I have a long life token.
I tried https://xxxxxxxxxxx.ui.nabu.casa/api/states/my_sensor?Authorization=Bearer_(long_life_token) which does not work either…
I have added api: to my config.yaml.
Any thoughts?
mattdm
(Matthew Miller)
April 13, 2023, 3:14am
2
You need to put the token in a request header , not as a parameter in the URL.
andypnz
(Andrew Palmer)
April 13, 2023, 4:34am
3
Thanks…
So the Nabu Casa url should work, whne using Word press and WPGetAPI?
Base URL is https://xxxxxxxxxxxxxxxxxx.ui.nabu.casa/api
Endpoint is /states/sensor.my_sensor
Headers - Authorization: Bearer (long life token)
Content-Type: Application/json
When I use the ‘test’ button in WPGet, it returns unauthorized
Hummm… now getting ‘invalid header token’
Any ideas?
andypnz
(Andrew Palmer)
April 13, 2023, 5:01am
4
Sorted
I had included a ‘:’ after Bearer - removed that and all good
1 Like