mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[homeconnect] Remove the access token when the thing is removed (#14935)
Related to #14818 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
3ae72c92e5
commit
4e8e39cd9f
@ -84,7 +84,7 @@ public class HomeConnectBridgeHandler extends BaseBridgeHandler {
|
||||
private @Nullable List<Event> eventHistory;
|
||||
|
||||
private @NonNullByDefault({}) OAuthClientService oAuthClientService;
|
||||
private @NonNullByDefault({}) String oAuthServiceHandleId;
|
||||
private @Nullable String oAuthServiceHandleId;
|
||||
private @NonNullByDefault({}) HomeConnectApiClient apiClient;
|
||||
private @NonNullByDefault({}) HomeConnectEventSourceClient eventSourceClient;
|
||||
|
||||
@ -221,6 +221,15 @@ public class HomeConnectBridgeHandler extends BaseBridgeHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRemoval() {
|
||||
String handleId = this.oAuthServiceHandleId;
|
||||
if (handleId != null) {
|
||||
oAuthFactory.deleteServiceAndAccessToken(handleId);
|
||||
}
|
||||
super.handleRemoval();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Class<? extends ThingHandlerService>> getServices() {
|
||||
return Collections.singleton(HomeConnectDiscoveryService.class);
|
||||
@ -285,7 +294,10 @@ public class HomeConnectBridgeHandler extends BaseBridgeHandler {
|
||||
eventSourceClient.getLatestEvents().clear();
|
||||
eventSourceClient.dispose(immediate);
|
||||
|
||||
oAuthFactory.ungetOAuthService(oAuthServiceHandleId);
|
||||
String handleId = this.oAuthServiceHandleId;
|
||||
if (handleId != null) {
|
||||
oAuthFactory.ungetOAuthService(handleId);
|
||||
}
|
||||
homeConnectServlet.removeBridgeHandler(this);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user