[tesla] Clarify and update how refresh tokens can be obtained (#12015)
* Clarify and update how refresh tokens can be obtained * Fix logging statement Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
parent
43384fe9fc
commit
35d7d9d6dd
|
@ -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`.
|
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
|
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.
|
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
|
## Thing Configuration
|
||||||
|
|
||||||
The vehicle Thing requires the vehicle's VIN as a configuration parameter `vin`.
|
The vehicle Thing requires the vehicle's VIN as a configuration parameter `vin`.
|
||||||
|
|
|
@ -207,7 +207,8 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
||||||
Response response = vehiclesTarget.request(MediaType.APPLICATION_JSON_TYPE)
|
Response response = vehiclesTarget.request(MediaType.APPLICATION_JSON_TYPE)
|
||||||
.header("Authorization", authHeader).get();
|
.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)) {
|
if (!checkResponse(response, true)) {
|
||||||
logger.error("An error occurred while querying the vehicle");
|
logger.error("An error occurred while querying the vehicle");
|
||||||
|
@ -335,9 +336,9 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkResponse(response, false)) {
|
if (!checkResponse(response, false)) {
|
||||||
logger.debug("An error occurred while communicating with the vehicle during request {}: {}:{}", command,
|
logger.debug("An error occurred while communicating with the vehicle during request {}: {}: {}",
|
||||||
(response != null) ? response.getStatus() : "",
|
command, (response != null) ? response.getStatus() : "",
|
||||||
(response != null) ? response.getStatusInfo() : "No Response");
|
(response != null) ? response.getStatusInfo().getReasonPhrase() : "No Response");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,6 +166,7 @@ public class TeslaSSOHandler {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Document doc = Jsoup.parse(loginPageResponse.getContentAsString());
|
Document doc = Jsoup.parse(loginPageResponse.getContentAsString());
|
||||||
|
logger.trace("{}", doc.toString());
|
||||||
Element loginForm = doc.getElementsByTag("form").first();
|
Element loginForm = doc.getElementsByTag("form").first();
|
||||||
|
|
||||||
Iterator<Element> elIt = loginForm.getElementsByTag("input").iterator();
|
Iterator<Element> elIt = loginForm.getElementsByTag("input").iterator();
|
||||||
|
|
Loading…
Reference in New Issue