]> git.basschouten.com Git - openhab-addons.git/commitdiff
[tesla] Clarify and update how refresh tokens can be obtained (#12015)
authorKai Kreuzer <kai@openhab.org>
Mon, 10 Jan 2022 08:54:31 +0000 (09:54 +0100)
committerGitHub <noreply@github.com>
Mon, 10 Jan 2022 08:54:31 +0000 (09:54 +0100)
* Clarify and update how refresh tokens can be obtained
* Fix logging statement

Signed-off-by: Kai Kreuzer <kai@openhab.org>
bundles/org.openhab.binding.tesla/README.md
bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/handler/TeslaAccountHandler.java
bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/handler/TeslaSSOHandler.java

index aebe741032bed59e704a75d9ae467822702c1721..8145e96965a28fcc50cd53d0b1aed19ac590ab88 100644 (file)
@@ -27,7 +27,10 @@ Furthermore, once an account is configured, it is automatically queried for asso
 
 The `account` bridge requires an OAuth2 refresh token as the only parameter `refreshToken`.
 
-There are two different ways of obtaining the token:
+There are three different ways of obtaining the token.
+
+NOTE: Tesla has introduced some captcha mechanism, which might prevent options 1 and 2 from working as expected.
+In case you are only receiving error messages, please make use of option 3!
 
 1. Use the openHAB console
 
@@ -50,6 +53,18 @@ If you do not want to use the openHAB console, you can also manually create a "T
 
 openHAB will use the provided credentials to retrieve and set the refresh token and automatically delete your password from the configuration afterwards for safety reasons.
 
+3. Use external tools
+
+There are a few 3rd party tools available that have specialized on getting hold of refresh tokens for the Tesla API.
+Please note that we in general consider it dangerous to enter your credentials into some 3rd party app - you will have to trust the author not to send or store those credentials anywhere.
+
+- [Tesla Access Token Generator (Chromium Extension](https://github.com/DoctorMcKay/chromium-tesla-token-generator)
+- [Auth App for Tesla (iOS)](https://apps.apple.com/us/app/auth-app-for-tesla/id1552058613)
+- [Tesla Tokens (Android)](https://play.google.com/store/apps/details?id=net.leveugle.teslatokens)
+
+When using one of such apps, simply copy and paste the received refresh token into the account configuration.
+
+
 ## Thing Configuration
 
 The vehicle Thing requires the vehicle's VIN as a configuration parameter `vin`.
index d41e4cbcbc0e40e75781b6746eb96a74f35b02ab..6dc54226db4e541d940a4cf22e9a1ba20981af6c 100644 (file)
@@ -207,7 +207,8 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
             Response response = vehiclesTarget.request(MediaType.APPLICATION_JSON_TYPE)
                     .header("Authorization", authHeader).get();
 
-            logger.debug("Querying the vehicle: Response: {}:{}", response.getStatus(), response.getStatusInfo());
+            logger.debug("Querying the vehicle: Response: {}: {}", response.getStatus(),
+                    response.getStatusInfo().getReasonPhrase());
 
             if (!checkResponse(response, true)) {
                 logger.error("An error occurred while querying the vehicle");
@@ -335,9 +336,9 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
             }
 
             if (!checkResponse(response, false)) {
-                logger.debug("An error occurred while communicating with the vehicle during request {}: {}:{}", command,
-                        (response != null) ? response.getStatus() : "",
-                        (response != null) ? response.getStatusInfo() : "No Response");
+                logger.debug("An error occurred while communicating with the vehicle during request {}: {}: {}",
+                        command, (response != null) ? response.getStatus() : "",
+                        (response != null) ? response.getStatusInfo().getReasonPhrase() : "No Response");
                 return null;
             }
 
index 749733ec9ccebb8998ccf94dd38c72e8777e484a..ff292d70915eedd8b2a8780f1796fa741c88e661 100644 (file)
@@ -166,6 +166,7 @@ public class TeslaSSOHandler {
 
             try {
                 Document doc = Jsoup.parse(loginPageResponse.getContentAsString());
+                logger.trace("{}", doc.toString());
                 Element loginForm = doc.getElementsByTag("form").first();
 
                 Iterator<Element> elIt = loginForm.getElementsByTag("input").iterator();