]> git.basschouten.com Git - openhab-addons.git/commitdiff
[myq] Remove the access token when the thing is removed (#14938)
authorlolodomo <lg.hc@free.fr>
Fri, 5 May 2023 21:22:20 +0000 (23:22 +0200)
committerGitHub <noreply@github.com>
Fri, 5 May 2023 21:22:20 +0000 (23:22 +0200)
* [myq] Remove the access token when the thing is removed
* oAuthService.removeAccessTokenRefreshListener added

Related to #14818

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

index d70721b0b4f591bb50d7927df97859c8f96c32bd..a533321fa8e052f2d1e034c59860ee54d8e764d1 100644 (file)
@@ -162,10 +162,21 @@ public class MyQAccountHandler extends BaseBridgeHandler implements AccessTokenR
         stopPolls();
         OAuthClientService oAuthService = this.oAuthService;
         if (oAuthService != null) {
-            oAuthService.close();
+            oAuthService.removeAccessTokenRefreshListener(this);
+            oAuthFactory.ungetOAuthService(getThing().toString());
+            this.oAuthService = null;
         }
     }
 
+    @Override
+    public void handleRemoval() {
+        OAuthClientService oAuthService = this.oAuthService;
+        if (oAuthService != null) {
+            oAuthFactory.deleteServiceAndAccessToken(getThing().toString());
+        }
+        super.handleRemoval();
+    }
+
     @Override
     public Collection<Class<? extends ThingHandlerService>> getServices() {
         return Collections.singleton(MyQDiscoveryService.class);