Withings Integration 2022.4.2: "redirect_uri_mismatch" error

Hey all,

I was wondering if anyone has successfully integrated Withings with their HA install. I’ve followed the instructions here, Withings - Home Assistant, for HA Cloud integration and I’ve been stuck on STEP 3 - AUTHORIZE HOME ASSISTANT. When ever I click the “Allow This App” button I’m redirected to a page stating:

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

I’ve double checked and my app is configured with the correct url according to those instructions. A search showed me a few other posts that have mentioned this happening before, unfortunately none of those solutions solved the issue. I’m also aware that Withings is going through an API change but I was unable to determine if this integration had already been updated to handle those breaking changes.

One thing I’ve tried already is manually defining my internal_url and external_url in my configuration.yaml instead of handling it in the UI settings. That didn’t work either :sob:

Any insight or possible solutions would be greatly appreciated. :pray:

1 Like

Finally solved it. For anyone experiencing the same issue I would suggest double checking a few things:

  • Ensure the protocol is set to https and not http
  • Remove www before your Nabu Casa ID
  • Finally check to ensure there is no trailing slash i.e. /auth/external/callback/ <— This was my issue
2 Likes

Sad to say you’ll be tired of reauthenticating every other day. I just gave up on this stupid integration.

1 Like

Hi.

Thanks for that, but can you expand it a bit? Which protocol are you referring to? the protocol in the url for the external_url settings in the configuration.yml file?

The trailing slash is in the url on the console?

Trying to get this working but having a hard time so far…

Also, I’m running HA in Docker with a Reverse proxy in front of it for external access, if that is important.

I think it is the callback URI he is referring to on the withings dashboard_oauth2.

Also, I found I had enabled restriced mode and once I switched that off it worked.

Trying to setup withings. however during setup it redirects to the withings app page and ask if the app should be granted access. when i acknowledge this the failure pops up [redirect_uri_mismatch” error]

i simply followed the instructions omn the HA INtegration page. The problem now is, i can’t even delete or disable withings form HA.

So what is required to get this to work? It doesnt seem to be straight out of the box experience

I had the same error after the normal install process and solved it by defining in the configuration.yml file :

http:
    base_url: https://MYDOMAIN.duckdns.org:433

I found the solution here.

I am also ending up with redirect_uri_mismatch when trying to activate the Withings integration.
Setting base_url doesn’t work for me. Probably a good thing, because it is deprecated anyway.
Since I only get to the point of activating the integration at Withings with correctly set external URL in network settings, I hope that everything is good on this side.

I am very happy for the my Home Assistant service’s existance, since I am using a port in my personal URL which is not supported by Withings. @allenporter: May I draw you into this? Generally my seems to work for most people and it looks to be working fine for me as well until Withings tell me how unhappy they are about my URL. :wink:
It shouldn’t be related to anything in my public URL (be it certificate, port, or whatever) when I am using my, right?

The documentation correctly says how to configure the redirect url Withings - Home Assistant

Your base url doesn’t matter, unless you disabled default config/ my home assistant.

I followed the documentation to the letter and Withings at first accepts https://my.home-assistant.io/redirect/oauth as callback URI.
But then during configuration (no matter if via my service or manually) after clicking on “accept this app” I’ll get the {"errors":[{"message":"redirect_uri_mismatch: The redirect URI provided is missing or does not match partner callback url"}]} response. :man_shrugging:

Does it tell you what url it thinks you are using or can you tell in the url what url is embedded inside ss the redirect url?

Before you rip your hair out, there are currently a few open bugs on the redirect URI in the Withings Integration:

Withings webhook not working · Issue #72614 · home-assistant/core (github.com)
Withings Callback URL Incorrect - Nabu Casa · Issue #73200 · home-assistant/core (github.com)

Read them - including the intervention steps and see if either case applies.

Interesting!
Following through my Home Assistant it tries to open the following link which leads to the Withings page but ends in the error:
https://account.withings.com/oauth2_user/authorize2?response_type=code&client_id=[ID here]&redirect_uri=[external HA url here]/auth/external/callback&state=[lenghty token here]scope=user.info,user.metrics,user.activity,user.sleepevents

Replacing [external HA url here]/auth/external/callback with https://my.home-assistant.io/redirect/oauth prevents the mismatch error and I am getting one step further getting asked by my Home Assistant if I want to link the account. Confirming this leads to a simple “error” message in Home Assistant though.

So it sounds like my home assistant is disabled.

Hmm. How would I check?
default_config is included and to be sure, I now added my: to configuration.yaml.
And clicking the my… links triggers actions within my HA.
Can’t spot anything in the logs either.

Sorry, only seeing your comment now.
I read through this. It all seems to lead to this workaround: https://github.com/home-assistant/core/issues/72614#issuecomment-1152366510
However, I don’t use the cloud service and already played around a bit with the external URL. Any advise what to put here if not my external URL?

Might be an old thread.

In you configuration.yaml

add

my:

This re-enables the My Home Assistant which handles the call back - and is often missing on upgraded installs (its there by default on new installs)

Then set the callback URL as it says in the instructions

2 Likes

Just in case others also experience this, here’s what worked for me after the integration stopped working a couple of weeks ago…there may also be some bugs, but I think what’s actually happening is that people who have had it working for a while are not aware of the full configuration changes that now need to be made to keep it working:

  1. Add my: to configuration.yaml if it’s not already there (old install in my case, never had it)

  2. In the Withings Developer Portal, have Link to OAuth2 Authorize Callback – My Home Assistant as your Callback URL (mine wasn’t this, because the Withings integration had been configured ages ago)

  3. Configure the URL in https://my.home-assistant.io to be whatever URL you’re actually using to set this stuff up (in my case, the Nabu Casa URL). This is key, because if you’re using a local IP in the browser while setting this up on your PC but the URL in https://my.home-assistant.io is an external one, like the Nabu Casa URL, the Withings setup will not work!

  4. Setup the Withings integration

Good luck!

4 Likes

Until your post I have not been able to find a callback URL that the developer dashboard would accept. So thanks for that!

I’ve also added “my:” to my configuration.yaml

Unfortunately, following the authorization page I am still getting the infamous:
{"errors":[{"message":"redirect_uri_mismatch: The redirect URI provided is missing or does not match partner callback url"}]}

I am super new to this environment. Would you mind providing a bit more color as to what I should be doing at Link to OAuth2 Authorize Callback – My Home Assistant

Any advice or additional context is greatly appreciated!

image

The only difference vs. mine seems to be your Callback URL, which I set to https://my.home-assistant.io/redirect/oauth

1 Like