Integration Toon stopped working

Hello,

Since yesterday my Toon integration just stopped working with this error:

[homeassistant.components.toon.config_flow] Unexpected error while authenticating

I checked all my credentials and API tokens and they’re all correct.
So I removed the integration, rebooted HA and tried to re-add the integration but below error keeps showing up (telling me that my credentials are not correct, while I know that they are correct because I just logged in using the same credentials).

image

I checked suggestions from other topics (to login on eneco.nl and check if all your products are correct and have an active Toon subscription) but everything is fine and correct.
I also don’t see any logs about Toon anymore after removing the integration and the reboot.

What could be wrong?

1 Like

See here

1 Like

Thank you I never found that one!

i have exactly the same problem it started 3 days ago

Welcome @SultanSoner,

Like @Tinkerer pointed out, it is a known issue and it will be addressed.

thank you Cris

I have the same issue with Toon since 2 weeks now. Lucky I saw this morning an update of Home Assistant towards 0.112 BETA.

After the update, I got a notification that Toon can be integrated. After pushing the configuration button and selecting Eneco, I was forwarded to an external URL with the following error:

# Developer hint:
The requested redirect_uri does not match any of the whitelisted redirect_uris on the Toon developer page.
Make sure to allow the requested redirect_uri on your registered Toon app in the developer pages
Multiple redirect_uris can be used, separated by a comma.

What did I do wrong? Should I generate a new key?

Hi Martijn,
I just ran in the same issue here. I run the stable 0.112 version…

Also i wanted to check my API key’s at: https://developer.toon.eu/

There seems to be an issue with this site aswell. The hosting provider did not set the proper cert but enabled HSTS… There is not much we can to do work around this :frowning: Let’s hope they will solve the issues…
R.

Hi,

I manged to get it to work!

You need to get into the https://developer.toon.eu/user/me/apps (i was able to just accept the incorrect https cert) page and add the internal uri for your HA setup. You can find it as one of the parameters in the called url, which returns the error…

After a couple of minutes, the “Open website” in HA brought me to the actual Eneco login page, now i can mange Toon again.

R.

I’, sorry but can you please explain what exactly needs to be done, I’m sick of troubleshooting this issue with no luck. What needs to be put in configuration yaml file exactly? What needs to be added to that dem Callback URL on toon developer website?! What exactly ? Do I need to open firewall on my router and allow traffic from toon website? Do I need to add port’s redirect on my router What ? PLS help, I’m really annoyed by that crap.

Hello,

I’ve tried several times to get Toon to work, but I can’t get it to work.

In developper toon I put in the Callback URL http://192.168.1.**:8123/auth/external/callback

But nothing makes it so it sends me back to an error of the type: 500 Internal Server Error
Server got itself in trouble

Thank you for your help

Logger: aiohttp.server
Source: components/toon/oauth2.py:134 
First occurred: 15:28:30 (2 occurrences) 
Last logged: 15:29:00

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 136, in get
    return await super().get(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 92, in get
    result = await self._flow_mgr.async_configure(flow_id)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 153, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 201, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 259, in async_step_creation
    token = await self.flow_impl.async_resolve_external_data(self.external_data)
  File "/usr/src/homeassistant/homeassistant/components/toon/oauth2.py", line 104, in async_resolve_external_data
    return await self._token_request(data)
  File "/usr/src/homeassistant/homeassistant/components/toon/oauth2.py", line 134, in _token_request
    resp.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 946, in raise_for_status
    headers=self.headers)
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url='https://api.toon.eu/token

The problem I have now with Toon is the following. Since version 0.112 it did briefly work. But yesterday I found out it had already broke again.

Error setting up entry [home address] for toon

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/config_entries.py”, line 220, in async_setup
hass, self
File “/usr/src/homeassistant/homeassistant/components/toon/init.py”, line 102, in async_setup_entry
agreement_id=entry.data[CONF_AGREEMENT_ID]
File “/usr/local/lib/python3.7/site-packages/toonapi/toon.py”, line 155, in activate_agreement
await self.agreements()
File “/usr/local/lib/python3.7/site-packages/toonapi/toon.py”, line 177, in agreements
f"/toon/{TOON_API_VERSION}/agreements", no_agreement=True
File “/usr/local/lib/python3.7/site-packages/backoff/_async.py”, line 133, in retry
ret = await target(*args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/backoff/_async.py”, line 133, in retry
ret = await target(*args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/toonapi/toon.py”, line 79, in _request
self.token = await self.token_refresh_method()
File “/usr/src/homeassistant/homeassistant/components/toon/coordinator.py”, line 35, in async_token_refresh
await session.async_ensure_token_valid()
File “/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py”, line 427, in async_ensure_token_valid
new_token = await self.implementation.async_refresh_token(self.token)
File “/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py”, line 79, in async_refresh_token
new_token = await self._async_refresh_token(token)
File “/usr/src/homeassistant/homeassistant/components/toon/oauth2.py”, line 115, in _async_refresh_token
new_token = await self._token_request(data)
File “/usr/src/homeassistant/homeassistant/components/toon/oauth2.py”, line 134, in _token_request
resp.raise_for_status()
File “/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py”, line 946, in raise_for_status
headers=self.headers)
aiohttp.client_exceptions.ClientResponseError: 400, message=’’, url='https://api.toon.eu/token

I have also problems with integration Toon - now I use Domoticz where a new plugin was made due to renewal op API of Toon? I have to use an access token which I obtained from https://api.toon.eu/toonapi-accesstoken?tenant_id=eneco&client_id=<consumer_key> - is this now also the problem within HA?

Hi, I have followed what you say but after enter my credentials in the Viesgo login page (I´m in Spain) it takes me back to HA but but nothing happened, I still can´t manage Toon.

I have to add myself to this. I am also getting the same error since a few days:

aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url='https://api.toon.eu/token

Is there anything we can do to help troubleshooting this?

Hi there,
is there a solution for this issue? is it broken since last summer… :frowning:

Hello, I got Toon working again. Problem seems lie in the extern_uri handling, where the current code uses the internal lan name of the server instead of the external name.

I made in an enhancement in development version of the toon integration. I includeded a code bypass in oauth2.py. After line 85 I added some some to include my one external server name.

def extra_authorize_data(self) -> dict:
    """Extra data that needs to be appended to the authorize url."""
    data = {"tenant_id": self.tenant_id}

    if self.issuer is not None:
        data["issuer"] = self.issuer
        data["redirect_uri"] = "<external servername:port>/Auth/external/callback" " <- this line added

Route that I have now discovered (and works) is to include the following in the configuration.yaml

homeassistant:
internal_url:
external_url:

You must also include the external server name in the callback url (http: // / auth / external / callback) in the service in developer.toon.eu and which belongs to your keys (consumer key Consumer Secret)

If you then access your Home Assistant via the external url (or via the App and external url) the Toon configuration process will run smoothly.

PS: Possible you need to include a port tforwarding rule in your home network router configuration to translate the :port to an :port

Hopefully it will work for you guys as well

1 Like

I solved this by removing Toon from my HA and doing a reboot. Then HA notfied me that a new instance was founf, when using the callback url I then received the error and was able to see what URL was found and updated the Toon app.

2024-04-16_13-56-17