From 88413c001dcc58a7ed72214c77fd9f7a7343749b Mon Sep 17 00:00:00 2001 From: lolodomo Date: Thu, 11 May 2023 22:03:00 +0200 Subject: [PATCH] [webexteams] Remove the access token when the thing is removed (#14979) Related to #14818 Signed-off-by: Laurent Garnier --- .../internal/WebexTeamsHandler.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bundles/org.openhab.binding.webexteams/src/main/java/org/openhab/binding/webexteams/internal/WebexTeamsHandler.java b/bundles/org.openhab.binding.webexteams/src/main/java/org/openhab/binding/webexteams/internal/WebexTeamsHandler.java index b317f0c3f..16eb61b14 100644 --- a/bundles/org.openhab.binding.webexteams/src/main/java/org/openhab/binding/webexteams/internal/WebexTeamsHandler.java +++ b/bundles/org.openhab.binding.webexteams/src/main/java/org/openhab/binding/webexteams/internal/WebexTeamsHandler.java @@ -147,11 +147,17 @@ public class WebexTeamsHandler extends BaseThingHandler implements AccessTokenRe OAuthClientService authService = this.authService; if (authService != null) { authService.removeAccessTokenRefreshListener(this); + oAuthFactory.ungetOAuthService(thing.getUID().getAsString()); } - oAuthFactory.ungetOAuthService(thing.getUID().getAsString()); cancelSchedulers(); } + @Override + public void handleRemoval() { + oAuthFactory.deleteServiceAndAccessToken(thing.getUID().getAsString()); + super.handleRemoval(); + } + private void createIntegrationOAuthClientService(WebexTeamsConfiguration config) { String thingUID = this.getThing().getUID().getAsString(); logger.debug("Creating OAuth Client Service for {}", thingUID); @@ -369,7 +375,7 @@ public class WebexTeamsHandler extends BaseThingHandler implements AccessTokenRe /** * Send a message to a specific room - * + * * @param roomId roomId of the room to send to * @param msg markdown text string to be sent * @return true, if sending the message has been successful and @@ -385,11 +391,11 @@ public class WebexTeamsHandler extends BaseThingHandler implements AccessTokenRe /** * Send a message to a specific room, with attachment - * + * * @param roomId roomId of the room to send to * @param msg markdown text string to be sent * @param attach URL of the attachment - * + * * @return true, if sending the message has been successful and * false in all other cases. */ @@ -404,7 +410,7 @@ public class WebexTeamsHandler extends BaseThingHandler implements AccessTokenRe /** * Sends a message to a specific person, identified by email - * + * * @param personEmail email address of the person to send to * @param msg markdown text string to be sent * @return true, if sending the message has been successful and @@ -420,7 +426,7 @@ public class WebexTeamsHandler extends BaseThingHandler implements AccessTokenRe /** * Sends a message to a specific person, identified by email, with attachment - * + * * @param personEmail email address of the person to send to * @param msg markdown text string to be sent * @param attach URL of the attachment* @@ -438,7 +444,7 @@ public class WebexTeamsHandler extends BaseThingHandler implements AccessTokenRe /** * Sends a Message - * + * * @param msg the Message to be sent * @return true, if sending the message has been successful and * false in all other cases.