-
-
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
[Tesla] Add SSO handler to authenticate against Tesla SSO service #10259
Conversation
Signed-off-by: Christian Güdel <[email protected]>
Signed-off-by: Christian Güdel <[email protected]>
Signed-off-by: Christian Güdel <[email protected]>
Looks like a productive weekend, thanks! |
First feedback: Creating an account thing (without filling in credentials or token) in the UI immediately results in two errors in the log:
|
Second feedback: Vehicle discovery crashes with an exception:
|
Interesting... could be that you get throttled by Tesla's WAF and the logon page now looks different. Will need to see if I can reproduce that. The second thing looks very odd and not really related to the changes, more like a certificate issue? |
Will try to investigate myself as well. FTR: I am running the binding from within the IDE. |
I was doing the same, Eclipse on Windows with Java 11, FWIW. |
I know there is still one problem with the SSO handler. In case you successfully logged in on the SSO endpoint using username/password and try this again, it directly skips the sign in step upon fetching the login form. This is currently not (yet) handled by the handler. But never saw those two issues/exceptions you just posted |
The exceptions are not fully reproducible. Now the discovery starts and I can see in the debugger that it has the correct vehicleArray, but the call in this line results in an HTTP 408, which again makes the discovery return no results. Pretty weird... |
Ah, the 408 means that the vehicle is asleep and you need to wake it up first. That's a trap that was in there before and I also fell into it the first time the discovery of the account actually worked :) |
Thanks - indeed, waking up the vehicle made it being discovered. Maybe something that could be improved, but not within this PR. |
Another exception that asks to be fixed:
|
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.
Code wise it looks excellent! Looking forward to more contributions from you ;-)
A few small change requests below.
....binding.tesla/src/main/java/org/openhab/binding/tesla/internal/handler/TeslaSSOHandler.java
Outdated
Show resolved
Hide resolved
....binding.tesla/src/main/java/org/openhab/binding/tesla/internal/handler/TeslaSSOHandler.java
Outdated
Show resolved
Hide resolved
....binding.tesla/src/main/java/org/openhab/binding/tesla/internal/handler/TeslaSSOHandler.java
Show resolved
Hide resolved
...n/java/org/openhab/binding/tesla/internal/protocol/SSO/AuthorizationCodeExchangeRequest.java
Outdated
Show resolved
Hide resolved
...n/java/org/openhab/binding/tesla/internal/protocol/SSO/AuthorizationCodeExchangeRequest.java
Outdated
Show resolved
Hide resolved
.../java/org/openhab/binding/tesla/internal/protocol/SSO/AuthorizationCodeExchangeResponse.java
Outdated
Show resolved
Hide resolved
...tesla/src/main/java/org/openhab/binding/tesla/internal/protocol/SSO/RefreshTokenRequest.java
Outdated
Show resolved
Hide resolved
.../java/org/openhab/binding/tesla/internal/protocol/SSO/AuthorizationCodeExchangeResponse.java
Outdated
Show resolved
Hide resolved
...esla/src/main/java/org/openhab/binding/tesla/internal/protocol/SSO/TokenExchangeRequest.java
Outdated
Show resolved
Hide resolved
Skip the form submit in this case and directly proceed to exchange the received authorization code for an access token Signed-off-by: Christian Güdel <[email protected]>
Replace random string generation with pure java Signed-off-by: Christian Güdel <[email protected]>
@kaikreuzer Thanks for the quick review! I added the changes requested. Not sure what to do about the exceptions though. The very first one with the buffer capacity error seems very weird. The others I would say were already in :) |
Annotate TeslaSSOHandler and methods Change most of logging calls to debug Documentation changes Signed-off-by: Christian Güdel <[email protected]>
0be21b0
to
9dc1762
Compare
I haven't seen it ever again, so let's ignore it. I am fine to merge it like it is, though, and we can see what testing by others bring up. I might do a follow-up PR for handling this exception gracefully then. |
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.
Many thanks, let's get that into the SNAPSHOT distro and have people test it!
FTR: The fix is now included in distro build 2230 - would be great if everyone could test it! |
I'll check if I can see the same on my side |
Just downloaded the lastest snapshot from https://openhab.jfrog.io/artifactory/libs-pullrequest-local/org/openhab/addons/bundles/org.openhab.binding.tesla/3.1.0-SNAPSHOT/org.openhab.binding.tesla-3.1.0-SNAPSHOT.jar Everything works fine! |
…0259) Signed-off-by: Christian Güdel <[email protected]>
Cherry-picked it to |
@cguedel and @kaikreuzer Thank you very much for your effort! I installed the snapshot jar file on my openhab version 3.0.1. Works like a charm again since 2 days. I also recognized the 408 exception (timeout due to sleeping vehicle), but it wakes up within a short time. I use it mainly to start/stop charging and display some vehicle information. |
…enhab#10259) Signed-off-by: Christian Güdel <[email protected]> Signed-off-by: John Marshall <[email protected]>
…enhab#10259) Signed-off-by: Christian Güdel <[email protected]>
…enhab#10259) Signed-off-by: Christian Güdel <[email protected]>
Stupid question, but is there any update on this binding ? |
…enhab#10259) Signed-off-by: Christian Güdel <[email protected]>
Signed-off-by: Christian Güdel [email protected]
Fixes #10016
Adds authentication against the Tesla SSO service as described here https://tesla-api.timdorr.com/api-basics/authentication