core icon indicating copy to clipboard operation
core copied to clipboard

Reconfigure error 500

Open Code-nomad opened this issue 1 year ago • 2 comments

The problem

The withings integration setup with webhook was working fine for a few days until it asked me to reconfigure.

I go through the documented steps to reauthorize the integration in the dev env of withings and it get to the link account screen upon authorizing.

After clicking "Link Account" I get an Error popup on my HomeAssistant page with no message body. If I click reconfigure again I am prompted by a 500 internal server error message.

I am at this point also unable to delete the integration as per my last screenshot.

image

image

image

image

image

What version of Home Assistant Core has the issue?

core-2023.03.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

home assistant supervised

Integration causing the issue

Withings

Link to integration documentation on our website

https://www.home-assistant.io/integrations/withings/

Diagnostics information

Screenshots of flow attached

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: aiohttp.server
Source: helpers/config_entry_oauth2_flow.py:324
First occurred: 10:24:31 PM (2 occurrences)
Last logged: 10:24:56 PM
Error handling request

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 67, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 171, in get
    return await super().get(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 96, in get
    result = await self._flow_mgr.async_configure(flow_id)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 324, in async_step_creation
    token["expires_in"] = int(token["expires_in"])
KeyError: 'expires_in'

Additional information

No response

Code-nomad avatar Mar 07 '23 21:03 Code-nomad

Hey there @vangorra, mind taking a look at this issue as it has been labeled with an integration (withings) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of withings can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign withings Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


withings documentation withings source (message by IssueLinks)

home-assistant[bot] avatar Mar 07 '23 21:03 home-assistant[bot]

Hello,

I've the same issue on my side

Home Assistant versions : Home Assistant 2023.3.5 Supervisor 2023.03.1 Operating System 9.5 Interface utilisateur : 20230309.1 - latest

Regards

ClementDy avatar Mar 20 '23 17:03 ClementDy

I get this error from the withings after authenticating and choosing the user: {"errors":[{"message":"redirect_uri_mismatch: The redirect URI provided is missing or does not match partner callback url"}]}

The redirect uri being passed is:

redirect_uri=https%3A%2F%2Fmy.home-assistant.io%2Fredirect%2Foauth&state=ey.......

jtbnz avatar Mar 21 '23 20:03 jtbnz

I have got this working now by: go into the withings developer portal https://developer.withings.com/dashboard/

Edit your application

Add another callback URL: https://my.home-assistant.io/redirect/oauth imageSave and then Reconfigure again

jtbnz avatar Mar 21 '23 20:03 jtbnz

On my side, i've already this configuration

ClementDy avatar Mar 22 '23 14:03 ClementDy

I also have this issue!

I was able to delete the Integration somehow, but now when adding it again, it skips the OAuth credentials popup and goes directly to the “open website” prompt. When clicking the link and approving the application, linking my HA install, and going back to HA, I get the 400: internal server error.

I have Nabu Casa, and it must be set up correctly in terms of outside connection to to my HA install because TTS with Google devices works just fine.

trashdaddy avatar Apr 26 '23 00:04 trashdaddy

Hi I had the same issue since yesterday. I could reactivate but this does not work and asks for a new regeneration; this gives a few minutes to remove the integration then I have renewed id and secret and re-add the integration so far so good ! Phil

pbranly avatar May 29 '23 15:05 pbranly

I have an issue, auth does seems to work, but always have 34 entities. Have a watch and scale. Where can i find where it goes wrong? Entities never get updated or real values...

b00tsie avatar Jul 21 '23 11:07 b00tsie

Same error here. I've tried multiple different options - my.homeassistant.io, NabuCasa Cloud URL and even Cloudflare Tunnel, nothing works. I do have Webhook working from my bed sensor though, but nothing else, as the integration requires reconfiguration. BTW, the integration worked for some time initially (maybe for a month), but then went into this "Requires Reconfiguration" state...

denix0 avatar Aug 13 '23 02:08 denix0

Plus 1

hdprice avatar Aug 26 '23 23:08 hdprice

Right, I just debugged this and made a fix for it. You probably have to renew your client secret for it to work again.

joostlek avatar Oct 08 '23 09:10 joostlek

Right, I just debugged this and made a fix for it. You probably have to renew your client secret for it to work again.

@joostlek thanks for fixing it! I'm trying to get it working, but still having some difficulties. Now I'm getting this error:

{"errors":[{"message":"redirect_uri_mismatch: The redirect URI provided is missing or does not match partner callback url"}]}

I'm getting this all the time - when tried to "Reconfigure" previously working integration. I also tried renewing the secret, tried creating the new application on Withings dev portal. I'm not being asked for the new ClientID and Secret on the HA side.

I even tried removing the Withings integration, rebooting and adding it again - it never asks for those 2 hashes, fails with the above error all the time right away.

I'm using Cloudflared tunnel, which I provide to Withings as https://<HOME_ASSISTANT_URL>/auth/external/callback per instructions. I also have that set in https://my.home-assistant.io and tried providing https://my.home-assistant.io/redirect/oauth to Withings app. Nothing seems to work.

Any pointers would be greatly appreciated! Thanks a lot.

denix0 avatar Oct 15 '23 20:10 denix0

Remove your credentials from https://my.home-assistant.io/redirect/application_credentials/

joostlek avatar Oct 15 '23 20:10 joostlek

@joostlek Aargh, I'm a complete moron! Somehow I missed that. Thank you!

BTW, just using https://<HOME_ASSISTANT_URL>/auth/external/callback didn't work and gave the same error, but https://my.home-assistant.io/redirect/oauth worked fine after a redirect to the same <HOME_ASSISTANT_URL>.

And the "In bed" sensor and its callback worked right away. So I'm up and running, finally! Thank you so much!

denix0 avatar Oct 15 '23 20:10 denix0

Yep, that's also how its described in the docs, use the my link if you did not disable the my integration :)

joostlek avatar Oct 15 '23 20:10 joostlek

Well, the documentation does say if the My integration is disabled, use the FQDN <HOME_ASSISTANT_URL> for the redirect. But it doesn't specifically say those are mutually exclusive - I was thinking the FQDN <HOME_ASSISTANT_URL> would always work regardless if the My integration is disabled or not. Apparently not... Thanks again for clarifying.

denix0 avatar Oct 15 '23 21:10 denix0