jwillemsen / daikin_onecta

Home Assistant Integration for devices supported by the Daikin Onecta App
https://github.com/jwillemsen/daikin_onecta
GNU General Public License v3.0
251 stars 9 forks source link

[Issue]: Using a custom redirect_uri as part of the HA setup doesn't work (yet) #45

Closed mihsu81 closed 7 months ago

mihsu81 commented 7 months ago

When trying to add the master d0f23e0 i get redirected to the Daikin proxy after which it opens a proxy error.

https://id.daikin.eu/b2c-oidc/eu/en/error.html?mode=error&message=The%2Bredirect%2BURI%2Bin%2Bthe%2Brequest%3A%2Bhttps%3A%2F%2Fbethayn-ha.duckdns.org%3A8123%2Fauth%2Fexternal%2Fcallback%2Bdid%2Bnot%2Bmatch%2Ba%2Bregistered%2Bredirect%2BURI.&code=invalid_request&skipConsent=false

image

This is the URL opened by the integration: https://idp.onecta.daikineurope.com/v1/oidc/authorize?response_type=code&client_id=emU20GdJDiiUxI_HnFGz69dD&redirect_uri=https://bethayn-ha.duckdns.org:8123/auth/external/callback&state=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmbG93X2lkIjoiOWE5YmU2MjQ4NGEzMGU5NWNlMDA1NDNlZTQ3ODE0ZDYiLCJyZWRpcmVjdF91cmkiOiJodHRwczovL2JldGhheW4taGEuZHVja2Rucy5vcmc6ODEyMy9hdXRoL2V4dGVybmFsL2NhbGxiYWNrIn0.GSOvQ2gFfHZ0uBhMdmWqyaj41godp_VXAeLtCqWNCas&scope=openid+onecta:basic.integration&client_secret=TNL1ePwnOkf6o2gKiI8InS8nVwTz2G__VYkv6WznzJGUnwLHLTmKYp-7RZc6FA3yS6D0Wgj_snvqsU5H_LPHQA

jwillemsen commented 7 months ago

I think the problem is that you are using a different redirect_uri, see https://developer.cloud.daikineurope.com/docs/b0dffcaa-7b51-428a-bdff-a7c8a64195c0/getting_started for a reference that only onectaintegration://callback/ should work, but Daikin has added https://my.home-assistant.io/redirect/oauth. You will have to wait until Daikin supports the creation of applications through the developer portal (where you can specify the redirect_uri) or see if you can support https://my.home-assistant.io/redirect/oauth

mihsu81 commented 7 months ago

How could I remove the custom redirect_uri? It's not something I set on purpose.

jwillemsen commented 7 months ago

See https://www.home-assistant.io/more-info/no-url-available/

mihsu81 commented 7 months ago

So you're using the Home Assistant Cloud to access remotely your HA instance and you're able to add the integration? I guess it's time for me to contribute by paying for the Nabu Casa Home Assistant Cloud.

jwillemsen commented 7 months ago

No, I am not using nabu, just using it locally, works for me

jwillemsen commented 7 months ago

I will try to find a better reference page tomorrow

jwillemsen commented 7 months ago

https://community.home-assistant.io/t/application-credentials-support-local-oauth-redirect-endpoints/490533/6

jwillemsen commented 7 months ago

Or https://community.home-assistant.io/t/home-connect-integration-error/440268/20

mihsu81 commented 7 months ago

Removing the URL from Settings/Network/Home Assistant URL didn't help. I had to add an empty

my:

in the configuration.yaml file. After which I removed my: because the SmartThings integration stopped working, restarted HA, and both integrations continued to work.

Thanks a lot for your suggestions. I'll check tomorrow if the token is refreshed properly.