Skip to content

Commit

Permalink
[groupepsa] Remove the access token when the thing is removed (openha…
Browse files Browse the repository at this point in the history
…b#14943)

Related to openhab#14818

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Matt Myers <mmyers75@icloud.com>
  • Loading branch information
lolodomo authored and matchews committed Aug 9, 2023
1 parent 605f1c8 commit a1abc32
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
package org.openhab.binding.groupepsa.internal.bridge;

import static org.openhab.binding.groupepsa.internal.GroupePSABindingConstants.THING_TYPE_BRIDGE;
import static org.openhab.binding.groupepsa.internal.GroupePSABindingConstants.VendorConstants;

import java.io.IOException;
import java.util.Collection;
Expand All @@ -26,6 +25,7 @@
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.groupepsa.internal.GroupePSABindingConstants.VendorConstants;
import org.openhab.binding.groupepsa.internal.discovery.GroupePSADiscoveryService;
import org.openhab.binding.groupepsa.internal.rest.api.GroupePSAConnectApi;
import org.openhab.binding.groupepsa.internal.rest.api.dto.Vehicle;
Expand Down Expand Up @@ -94,7 +94,10 @@ private void pollGroupePSAs() {
@Override
public void dispose() {
stopGroupePSABridgePolling();
oAuthFactory.ungetOAuthService(thing.getUID().getAsString());
if (oAuthService != null) {
oAuthFactory.ungetOAuthService(thing.getUID().getAsString());
oAuthService = null;
}
}

@Override
Expand Down Expand Up @@ -138,6 +141,14 @@ public void initialize() {
}
}

@Override
public void handleRemoval() {
if (oAuthService != null) {
oAuthFactory.deleteServiceAndAccessToken(thing.getUID().getAsString());
}
super.handleRemoval();
}

private void startGroupePSABridgePolling(@Nullable Integer pollingIntervalM) {
if (groupepsaBridgePollingJob == null) {
final long pollingIntervalToUse = pollingIntervalM == null ? DEFAULT_POLLING_INTERVAL_M : pollingIntervalM;
Expand Down

0 comments on commit a1abc32

Please sign in to comment.