-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[tado] Add OAuth authentication (deadline 2025-03-15) #18354
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
@andrewfg - I didn't look closely into the code, but is there anything that speaks against using the OAuth2 core classes? |
Sorry, didn't check the issue until now. I guess ideally RFC-8628 should be implemented as well in core. But I understand a short-term solution is needed. I'm wondering though if the core classes could still be partially used, i.e. having the responsibility of refreshing the token? See for example https://community.openhab.org/t/oauth2-0-device-authorization-grant-device-code/127070. Perhaps other bindings are already doing something similar? |
I looked at the core classes and I think it would be a very steep learning curve for me to implement the new workflow. I would prefer either a) someone else do that, or b) use my current solution for the time being, and eventually port it back to core. |
PS that does not offer any solution. Especially not to OH core. I am fairly sure that my Tado solution could eventually be taken over into core. But it needs a huge amount of study on the differences between a one binding solution and a possibly generic RFC compliant general solution. Also this PR is a migration from a legacy to a newer authentication model, and we don’t have the freedom to start from scratch. |
I fully understand. But did you consider this:
What I meant by this would be to simply use the store for persisting tokens through OAuthClientService. So you would implement your custom flow in the binding (which you already did), but you could then save the access token response, probably by calling importAccessTokenResponse. The benefits would be:
What is currently missing in core is the method of doing the initial authentication, but everything after that should be supported already. If you want to go down this path, I can offer my assistance. Btw, I did something similar in the Bosch Indego binding. I could not use any standard grant flow, so I had to provide a hacky way for obtaining the code. After that I was then able to use the core implementation for storing and maintaining tokens. |
Another binding I recently changed to take that approach is the BMW binding. It just uses the store and the token refresh mechanism, not the initial grant flow. |
Ok. I will give that a try today. |
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Ok. I refactored the code in order to prepare for an easier migration of the "device code grant flow" into OH core. The prior code is split into two parts -- namely the tado specific part that stays in the binding and the generic part that could eventually be migrated into OH Core. I won't yet move it into core, since I want to test it well. I was not able to use the oAuth store for persisting the "device code grant flow" results, so for the time being I am persisting that in the thing handler configuration instead. |
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Migrated the oAuth workflow into openhab/openhab-core#4632 |
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
@mherwege / @jlaur I have implemented oAuth RFC-8628 in openhab/openhab-core#4632 and tested it on this PR. But I need your help please, concerning Specifically I wrote a class Now after the initial token, the binding is supposed to use the EXISTING
EDIT I think it is this https://community.openhab.org/t/fix-for-jetty-error-when-running-on-host-with-many-cores/57449 .. I am testing on an Intel machine with 20 cores :) => I wonder if this is something that should be auto- fixed during OH setup? |
I ran into the same issue when developing the changes to the mybmw binding. Note that the only thing used from the core service is the token refresh as the way to get the token is mostly specific. I increased the defaults as suggested in the linked issue and didn’t have the problem anymore. I am not sure about this being linked entirely to the number of cores though. I am mostly developing on a pretty standard laptop. I don’t now the number of cores by heart (and I am not behind it) but I don’t think it is that much. |
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
fewer exceptions, refactoring, faster online Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Left some comments also need to wait for the upstream PR.
Signed-off-by: Andrew Fiddian-Green <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM
Resolves #18340
Depends on openhab/openhab-core#4632
Signed-off-by: Andrew Fiddian-Green [email protected]