]> git.basschouten.com Git - openhab-addons.git/commitdiff
[ecowatt] Remove the access token when the thing is removed (#14934)
authorlolodomo <lg.hc@free.fr>
Fri, 5 May 2023 20:35:09 +0000 (22:35 +0200)
committerGitHub <noreply@github.com>
Fri, 5 May 2023 20:35:09 +0000 (22:35 +0200)
Related to #14818

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/handler/EcowattHandler.java
bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/restapi/EcowattRestApi.java

index 13cf7735b361d9b4ee8757e30f54ffd9ea7bcd9c..c6fd16e6b06cd2307d3e3aa597f793da0c94628d 100644 (file)
@@ -116,6 +116,15 @@ public class EcowattHandler extends BaseThingHandler {
         }
     }
 
+    @Override
+    public void handleRemoval() {
+        EcowattRestApi localApi = api;
+        if (localApi != null) {
+            localApi.deleteServiceAndAccessToken();
+        }
+        super.handleRemoval();
+    }
+
     /**
      * Schedule the next update of channels.
      *
index 7da333721b3cf712b599237e7cfd15d0238e6ba8..c7f8d01fe4f2dbfdc8b186a734fee06d16d19174 100644 (file)
@@ -140,4 +140,8 @@ public class EcowattRestApi {
     public void dispose() {
         oAuthFactory.ungetOAuthService(authServiceHandle);
     }
+
+    public void deleteServiceAndAccessToken() {
+        oAuthFactory.deleteServiceAndAccessToken(authServiceHandle);
+    }
 }