From: lolodomo Date: Fri, 5 May 2023 21:22:20 +0000 (+0200) Subject: [myq] Remove the access token when the thing is removed (#14938) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=d3b7a0a98d6c42a960c308329861f84f54ab3e21;p=openhab-addons.git [myq] Remove the access token when the thing is removed (#14938) * [myq] Remove the access token when the thing is removed * oAuthService.removeAccessTokenRefreshListener added Related to #14818 Signed-off-by: Laurent Garnier --- 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 d70721b0b4..a533321fa8 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);