Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue]: OAuth failed - invalid_grant - token was issued to another client #187

Closed
MicheleM42 opened this issue May 9, 2024 · 31 comments
Closed

Comments

@MicheleM42
Copy link

MicheleM42 commented May 9, 2024

Good afternoon,

Since 3 days I'm trying to get this integration to work, but without success.
I signed up for the developer account, I created the APP as per instructions:
image

I get redirected to the Daikin website, I give permission, I link the account to my HA instance giving my internet address (not the local one) and when I get redirected to HA, this is the error:
image

This is the log:

2024-05-09 16:17:31.812 ERROR (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Error resolving OAuth token: 400, message='Bad Request', url=URL('https://idp.onecta.daikineurope.com/v1/oidc/token')
2024-05-09 16:21:24.506 DEBUG (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Resumed OAuth configuration flow
2024-05-09 16:21:24.513 DEBUG (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Creating config entry from external data
2024-05-09 16:21:24.514 DEBUG (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Sending token request to https://idp.onecta.daikineurope.com/v1/oidc/token
2024-05-09 16:21:24.777 ERROR (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Token request for daikin_onecta_qfiglpn5zwadxrp3xxxxxxxx failed (invalid_grant): The provided authorization code or refresh token was issued to another client.
2024-05-09 16:21:24.777 ERROR (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Error resolving OAuth token: 400, message='Bad Request', url=URL('https://idp.onecta.daikineurope.com/v1/oidc/token')

I deleted everything I found in my HA instance related to the old daikin residential integration.
I've tried to delete the daikin app in dev portal and refresh the tokens 10 times, changing browser and deleting cookies. But nothing helped.
Could you please help me to solve the issue?
thanks
Michele

@jwillemsen
Copy link
Owner

Have you tried the default redirect uri as mentioned in the readme as part of the application you configured at the daikin website?

@jwillemsen
Copy link
Owner

Have you restarted HA? Have you installed my home assistent? Have you tried to link to your local HA ip address?

@MicheleM42
Copy link
Author

In my very first try some days ago I put my HA address. But then I deleted the app and put https://my.home-assistant.io/redirect/oauth
I've tried restarting. I've just tried my home assistant (actually, I only added "my" to the configuration.yaml. Not sure it's enough).
image

And I also tried to put my local IP in the link account page. Try also the other method you explained after in the readme:
image
Still nothing.

@jwillemsen
Copy link
Owner

I have no idea at this moment how to solve this, please open an issue on HA core to ask for a feature to retrieve the redirect_uri as used by HA so that you can use the same uri at the daikin portal

@jjacobsson
Copy link

jjacobsson commented May 9, 2024

Just chiming in here to say I suffer the same issue.

2024-05-09 20:05:28.841 DEBUG (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Resumed OAuth configuration flow
2024-05-09 20:05:28.888 DEBUG (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Creating config entry from external data
2024-05-09 20:05:28.888 DEBUG (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Sending token request to https://idp.onecta.daikineurope.com/v1/oidc/token
2024-05-09 20:05:29.215 ERROR (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Token request for daikin_onecta_<REDACTED> failed (invalid_grant): The provided authorization code or refresh token was issued to another client.
2024-05-09 20:05:29.215 ERROR (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Error resolving OAuth token: 400, message='Bad Request', url=URL('https://idp.onecta.daikineurope.com/v1/oidc/token')

@jwillemsen
Copy link
Owner

Created an upstream issue home-assistant/core#117169. I did had this on my system also when starting, but after a HA restart and using https://my.home-assistant.io/redirect/oauth as redirect uri it now works

@jjacobsson
Copy link

Nice!

I noted you wrote "Home Assistant OS" as installation type, I am using the container in a kubernetes cluster... which probably makes things more complicated by several miles. I imagine that it won't be enough for me to know what Home Assistant sends as redirect_uri, I will need a way to actually set it... maybe.... I don't know, honestly guessing here :D

@jwillemsen
Copy link
Owner

Maybe contact @Daikin-Europe, maybe they can find what you are sending

@jwillemsen
Copy link
Owner

Did you got it working?

@jjacobsson
Copy link

@jwillemsen sorry, I have not been able to tinker with this, am out of town until this weekend!

@MicheleM42
Copy link
Author

I could write either to Daikin or HA Core team, but I'm a total noob and not sure what to ask..and I'm afraid of the questions I could get as response :D

@jwillemsen
Copy link
Owner

Send them the error and what you already tried, you can also add a link to this issue

@jwillemsen
Copy link
Owner

Any updates?

@muarqdnph4VPV6dyh
Copy link

Hi,

I don't know if I am right here but maybe I am lucky. I wanted to add the Daikin Onecta Integration to my Home Assistant, but I have problems with the Daikin Developer Portal. In particular I am not able to login to https://developer.cloud.daikineurope.com/

When I go to the site I see the "Continue with SSO" button. When I click it I get redirected to https://id.daikin.eu/ where I can insert my credentials. This seems to work.
However afterwards I am again redirected to the "Continue with SSO" button. If i click it again it just goes back and I am just stuck in an endless SSO loop.

What I also see is that the url in my browser is: https://developer.cloud.daikineurope.com/login?loginError=internal+error&loginSuccess=false

This happens every time, on every browser, with and without private mode. So it seems the issue is on Daikin side.
Did anyone else also had this issue and know how to get arounad this? Or does someone know where / how I can contact Daikin support?

Thanks in advance.

@jwillemsen
Copy link
Owner

@muarqdnph4VPV6dyh
Copy link

Thanks for the quick answer, but unfortunately no luck. I also only get redirected to the "Continue with SSO" page when I click this link where I am stuck in a loop.

@jwillemsen
Copy link
Owner

Have you restarted your system or use a different PC?

@jjacobsson
Copy link

jjacobsson commented May 24, 2024 via email

@jwillemsen
Copy link
Owner

All authorization is handled by HA, maybe ask if they can add some more logging to the HA application credentials support? I have created an issue to ask for a way to retrieve the redirect_uri, see home-assistant/core#117169

@jjacobsson
Copy link

jjacobsson commented May 24, 2024 via email

@muarqdnph4VPV6dyh
Copy link

Have you restarted your system or use a different PC?

yes, even tried it on a different PC and on my Phone, everytime the same result.
But in the meantime i found a general Daikin support form. Hopefully they can resolve this or forward it internally to the right team.

@jjacobsson
Copy link

Ok. So I had some time now to dig into this. And the problem is that you have hard-coded the client id & secret in config_flow.py on lines 93 & 94. These should be the values you make the user enter as part of the flow.

By the way you should probably generate new ones for yourself. Ahem.

@jjacobsson
Copy link

Ok now that is strange.

When checking the repo here, you don't have those lines. But when I check the .py files in install that were grabbed by HACS, I have hard-coded client id & secret....

@jwillemsen
Copy link
Owner

jwillemsen commented Jun 6, 2024

Do you have installed the latest version, in the past we had a client id/secret which was provided by Daikin

@jjacobsson
Copy link

That must be the problem... I guess I am fooled when I click HACS->Integrations->Daikin Onecta on my instance I am taken to this page:

bild

But I guess that is just pulling data of github and not actually telling me anything about what I have installed...

@jjacobsson
Copy link

No, re-installed. I still get a version installed that has a hard-coded client_id/secret.

@jwillemsen
Copy link
Owner

Try to remove it completely and install a fresh copy, did also had cases where HACS installed something differently as I thought

@jwillemsen
Copy link
Owner

jwillemsen commented Jun 6, 2024

Current installed version should be visible under config/integrations/integration/daikin_onecta, under device settings

@jjacobsson
Copy link

bild
I will try clean.

@jjacobsson
Copy link

Removed the repository in HACS. Removed the folder /config/custom/components/daikin_onecta. Restarted home assistant. Re-added the repository in HACS. Re-downloaded.

I now have version 4.1.3 installed and the configuration flow worked flawlessly.

@MicheleM42
Copy link
Author

I'm out of home these days so I can't operate on Ha yet. However I checked and I confirm I have id and secret hardcoded on my instance too.
I think we can close the issue. Many thanks for the kind support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants