How to use services like IFTTT & Webhooks using new Authentication?

I am trying to use IFTTT.com & Webhooks with the new authentication method.

I have created a long-live access token on my profile page.

The only example in the docs I can find is this:

I have put the following into the URL section on my Applet:
http://myaddress:8123/api/services/light/turn_on -H ‘Authorization: Bearer sillylongtoken’

I have also tried puting
-H ‘Authorization: Bearer sillylongtoken’
Into the Body section both before and after the command for the light.

The IFTTT.com log shows the following:
Unable to make web request. Your server returned a 401

I have the following in my Home Assistant log:
2018-09-23 08:45:51 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from (ip address)

Are there any examples on how to use the Access tokens, especially with the likes of IFTTT.com

Edit:
I read on another website where they are using Long-Lived Access tokens with Webhooks you can put the token in at the start of the address like:
http://token:@adress:8123/api/services/light/turn_on

But that doesn’t work either. One thing I have noticed its that when Home Assistant generates the token it puts in a couple of full stops ie . . But that wouldn’t work for a web address as it will think it’s a sub-domain?

I would like to know this too. For the moment I still have legacy api password enabled

Hi, see this topic for Google Assistant:

it works like this for me:

https://[YOUR HOME ASSISTANT URL:PORT]/api/google_assistant?token=[YOUR TOKEN]

but as pointed out by:

for now at least for me, I am waiting for someone to figure out how to do this properly with GA and IFTTT.

Thanks for the tip, sadly it’s not worked and I am still getting 401 error.

1 Like

Put token in the URL won’t work.

There is one proposal for short-lived token: https://github.com/home-assistant/home-assistant/issues/16745, it may not fit webhooks.
Another alternative solution is implement its own token system for each API, camera and media_player had done similar thing.

Pull request is always welcome

I am a bit surprised that it works for the Google Assistant …
Maybe it is still using the API password?

EDIT: I think the google assistant component need rewrite to leverage current HA auth system

My Google Assistant integration that I set up way back when it first came out does not require the API password at all. My GA is still working fine and I have disabled legacy_api.
If you check the docs on Github and use the history option to go back (to see how it was configured) you should still be able to set this up without using API password.

FYI: A discussion about webhook integration opened in architecture repo, https://github.com/home-assistant/architecture/issues/80

Hi, has anyone found an answer to this problem yet?
I have been using the legacy API and that has stopped working now.

I think you should use the new webhook component and the IFTTT integration (doc).

It roughly works like this:

  1. Activate the IFTTT integration in the integrations settings of HA
  2. Create an Applet with Webhook action on IFTTT
  3. Do a POST to https://your-ha/api/webhook/token-from-step-1
  4. The body could be eg. something like this:
{ "action": "call_service", "service": "input_boolean.turn_on", "entity_id": "input_boolean.alarm_clock_ringing" }
  1. Create an automation which listens for these webhooks and executes the called service:
automation:
  trigger:
    platform: event
    event_type: ifttt_webhook_received
    event_data:
      action: call_service
  action:
    service_template: '{{ trigger.event.data.service }}'
    data_template:
      entity_id: '{{ trigger.event.data.entity_id }}'

Yes, I have been using it for a while and it is working. If you want to use for multiple automations, you have to use the same webhook with a differentiator in the posted message. This differentiator should be used as condition in automation.

Can you give an example for that?