From: lolodomo Date: Fri, 5 May 2023 20:35:09 +0000 (+0200) Subject: [ecowatt] Remove the access token when the thing is removed (#14934) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=831a7af2c66d6af4181cced222fe32761bd359da;p=openhab-addons.git [ecowatt] Remove the access token when the thing is removed (#14934) Related to #14818 Signed-off-by: Laurent Garnier --- diff --git a/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/handler/EcowattHandler.java b/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/handler/EcowattHandler.java index 13cf7735b3..c6fd16e6b0 100644 --- a/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/handler/EcowattHandler.java +++ b/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/handler/EcowattHandler.java @@ -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. * diff --git a/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/restapi/EcowattRestApi.java b/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/restapi/EcowattRestApi.java index 7da333721b..c7f8d01fe4 100644 --- a/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/restapi/EcowattRestApi.java +++ b/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/restapi/EcowattRestApi.java @@ -140,4 +140,8 @@ public class EcowattRestApi { public void dispose() { oAuthFactory.ungetOAuthService(authServiceHandle); } + + public void deleteServiceAndAccessToken() { + oAuthFactory.deleteServiceAndAccessToken(authServiceHandle); + } }