]> git.basschouten.com Git - openhab-addons.git/commitdiff
[webexteams] Remove the access token when the thing is removed (#14979)
authorlolodomo <lg.hc@free.fr>
Thu, 11 May 2023 20:03:00 +0000 (22:03 +0200)
committerGitHub <noreply@github.com>
Thu, 11 May 2023 20:03:00 +0000 (22:03 +0200)
Related to #14818

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

index b317f0c3f463767175715739e096eb9304c557cd..16eb61b14a200301cb9be646a25076bf4e285410 100644 (file)
@@ -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 <code>true</code>, 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 <code>true</code>, if sending the message has been successful and
      *         <code>false</code> 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 <code>true</code>, 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 <code>Message</code>
-     * 
+     *
      * @param msg the <code>Message</code> to be sent
      * @return <code>true</code>, if sending the message has been successful and
      *         <code>false</code> in all other cases.