Mystrom button authentication

I’m trying to use the MyStrom buttons, and these work through an API call back to home assistant. I’m struggling with the authentication. I have an API password set:

  auth_providers:
    - type: homeassistant
    - type: trusted_networks
      trusted_networks:
        - 192.168.0.0/21
        - 192.168.1.40
        - 172.17.0.0/24
        - fd00::/8
    - type: legacy_api_password
      api_password: !secret api_password

However when I try to test the API with curl, I get 401 unauthorized:

$ curl -X GET -k "https://walker:8123/api/mystrom?api_password=##########&single=myStromButton01"
401: Unauthorized

I can get it working with a header and a bearer token:

$ curl -X GET -k -H 'Authorization: Bearer <LongToken>' "https://walker:8123/api/mystrom?single=myStromButton01"

however I don’t know how I can put a header into the MyStrom button config (I seem to only be able to program this with the URL (and the docs say to put api_password=##### into the URL, which is not working. The button (and the computer I was running curl from) are in the trusted network ranges.

Is there a way I can allow the switches to work without the token (using either api-password or by exempting them from authorisation?

Hi,
I tried to make my wifi buttons work with Home Assistant for days, but without success.

In addition it is written that the legacy_api_password will be dropped in a future release (See legacy-api-password)

I was so tired that I wrote a gateway mystrom button to MQTT.

I use the new generic action that comes with the firmware 2.74.10.

I put the code to the gateway here:

Best regards

Thanks for the advice, and especially for sharing the code!!