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.67k stars 30.81k forks source link

Withings oauth not working #105223

Closed stefanroelofs closed 11 months ago

stefanroelofs commented 11 months ago

The problem

According to the documentation I should go to the Withings Developer Portal and register this callback url:

https://my.home-assistant.io/redirect/oauth

However this does not work. The 'test url' button next to the url gives error: 'Partner error: Host Unreachable'. When I use the following callback url the test button works ok:

https://my.home-assistant.io/redirect/oauth/

(Note the trailing / )

In HA I see the message that I need to reconfigure my Withings integration. So I do the steps. But I get this error message:

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

Now if I change my url in the browser to add the missing / at the end, the authorisation continues and succeeds. This is my url:

https://account.withings.com/oauth2_user/authorize2?response_type=code&client_id=xxxx&redirect_uri=https%3A%2F%2Fmy.home-assistant.io%2Fredirect%2Foauth&state=xxxx&scope=user.info%2Cuser.metrics%2Cuser.activity%2Cuser.sleepevents&selecteduser=xxxx

So I add a %2F at the end of oauth.

But now I get the following error message in the HA log:

2023-12-07 11:26:06.352 WARNING (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Invalid token: {'status': 293, 'error': 'Wrong redirect_uri - Please use same as the one set to get authorization code'}

Thank you.

What version of Home Assistant Core has the issue?

core-2023.12.0

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

No response

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 11 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)

joostlek commented 11 months ago

Don't press the test button at withings and it will work iirc

stefanroelofs commented 11 months ago

Yeah sorry, it works now.

I had 2 applications in the Withings dev portal, and I think I connected to the wrong one with an old clientid.

My mistake. Thx for the quick reply 👍🏻