home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.31k stars 30.62k forks source link

Unable to add withings integration #124665

Open johnkiniston opened 2 months ago

johnkiniston commented 2 months ago

The problem

I am unable to setup a new withings integration.

I get the following error when I try and add the integration:

Logger: homeassistant.helpers.config_entry_oauth2_flow Source: helpers/config_entry_oauth2_flow.py:336 First occurred: 4:28:28 PM (1 occurrences) Last logged: 4:28:28 PM

Timeout resolving OAuth token:

The integration does successfully redirect me to the account.withings.com site and I am able to Allow the App I have created there.

I next get taken to the my.homeassistant.io redirect where my instance URL is configured as http://homeassistant.local:8123 and when I click Link account the page refreshes and eventually shows the Oath error.

What version of Home Assistant Core has the issue?

2024.8.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Withings

Link to integration documentation on our website

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

Diagnostics information

Logger: homeassistant.helpers.config_entry_oauth2_flow Source: helpers/config_entry_oauth2_flow.py:336 First occurred: 4:28:28 PM (1 occurrences) Last logged: 4:28:28 PM

Timeout resolving OAuth token:

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 2 months ago

Hey there @joostlek, 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. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


withings documentation withings source (message by IssueLinks)

MunaafN commented 2 months ago

The issue you're encountering with the Withings integration in Home Assistant appears to be related to OAuth token resolution, which is a known problem. This can happen due to various reasons, including incorrect redirect URIs, issues with cached credentials, or potential bugs in the integration itself.

Here are some steps you can try to resolve the issue:

  1. Update the Redirect URI:

    • Ensure that the redirect URI configured in your Withings developer application matches exactly with what is set in Home Assistant. Typically, this should be something like https://my.home-assistant.io/auth/external/callback. Double-check for typos or mismatches as these are common causes of the OAuth token timeout error【11†source】.
  2. Use a Stable URL:

    • When setting up the integration, make sure to access Home Assistant using a consistent and stable URL, such as https://my.home-assistant.io. Avoid using local URLs (e.g., http://homeassistant.local:8123) as these can sometimes cause issues with OAuth callbacks【12†source】.
  3. Clear OAuth Credentials:

    • If you’ve previously attempted to set up the integration and it failed, the old OAuth credentials might still be cached in Home Assistant. Try removing the integration, clearing any saved OAuth credentials, and then re-adding it. You might also need to recreate the OAuth application in the Withings developer portal to ensure a fresh start【13†source】.
  4. Reinstall or Roll Back:

    • If the issue persists, consider rolling back Home Assistant to a previous version where the integration was known to work, or reinstalling the integration entirely. Some users have reported that these steps helped them regain functionality.
joostlek commented 2 months ago

Please don't use chat gpt for this.

Try creating a new application at withings and try again.

The issue is mostly that your HA can't reach writings

johnkiniston commented 2 months ago

Hello, I am not using chat gpt anywhere in my homeassistant, I'm not sure where that was picked up?

As requested I created a new application and updated my credentials to use it, the old applications are pending deletion.

I still get the error Timeout resolving OAuth token.

I changed my https://my.home-assistant.io instance to point to my nabu casa cloud instead of homeassistant.local as listed above and even tried adding the cloud url as a secondary url at the withings developer portal.

I do see something that differs in the URL section above, the URL there is listed as

https://my.home-assistant.io/auth/external/callback

where the integration lists https://my.home-assistant.io/redirect/oauth

I do get an error from withings for both oath url's, I didn't include the cloud url in this screenshot for security but can if needed.

Screenshot 2024-08-27 at 9 22 08 AM
joostlek commented 2 months ago

Oh the user above me did, you didn't ^^

joostlek commented 2 months ago

If you have the my integration enabled, you need to use the my link (if you don't know what I'm talking about you didn't disable it)

Pressing the test button won't work, but it can succeed setup if you don't press it

johnkiniston commented 2 months ago

I have not disabled the my integration.

johnkiniston commented 2 months ago

What can I do to further troubleshoot this?

joostlek commented 2 months ago

How does your network set up look like? Anything special?

johnkiniston commented 1 month ago

No, nothing abnormal about my networking, Just a IPv4 with a single nat going on.

Do I need a port forward for this integration to work? I thought with the nabu cloud I wouldn't need one?

joostlek commented 1 month ago

You don't need to portforward indeed. Please check the documentation page, it got updated last weekend, maybe that helps

johnkiniston commented 4 weeks ago

No luck re-reading the documentation.

I verified I'm using the public cloud. I created a new application exactly as described with the my-homeassistant.io url I go to add it to home assistant and I still get the Timeout resolving OAuth token.

Some stuff I've tried. Using Chrome instead of Safari Using my nabu-casa cloud url instead of http://homeassistant.local:8123 in the my-homeassistant.io configuration. Setting up a port forward and using my public IP instead of http://homeassistant.local:8123 in the my-homeassistant.io configuration

In all cases I access Home Assistant via the url I'm configuring in my-homeassistant.io, IE via the nabu cloud or ip or just http://homeassistant.local:8123

Is there more debugging I can do?