diff --git a/bundles/org.openhab.binding.myq/src/main/java/org/openhab/binding/myq/internal/handler/MyQAccountHandler.java b/bundles/org.openhab.binding.myq/src/main/java/org/openhab/binding/myq/internal/handler/MyQAccountHandler.java index d70721b0b..a533321fa 100644 --- a/bundles/org.openhab.binding.myq/src/main/java/org/openhab/binding/myq/internal/handler/MyQAccountHandler.java +++ b/bundles/org.openhab.binding.myq/src/main/java/org/openhab/binding/myq/internal/handler/MyQAccountHandler.java @@ -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> getServices() { return Collections.singleton(MyQDiscoveryService.class);