[myq] Remove the access token when the thing is removed (#14938)

* [myq] Remove the access token when the thing is removed
* oAuthService.removeAccessTokenRefreshListener added

Related to #14818

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2023-05-05 23:22:20 +02:00 committed by GitHub
parent dea24b3dd8
commit d3b7a0a98d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -162,10 +162,21 @@ public class MyQAccountHandler extends BaseBridgeHandler implements AccessTokenR
stopPolls();
OAuthClientService oAuthService = this.oAuthService;
if (oAuthService != null) {
oAuthService.close();
oAuthService.removeAccessTokenRefreshListener(this);
oAuthFactory.ungetOAuthService(getThing().toString());
this.oAuthService = null;
}
}
@Override
public void handleRemoval() {
OAuthClientService oAuthService = this.oAuthService;
if (oAuthService != null) {
oAuthFactory.deleteServiceAndAccessToken(getThing().toString());
}
super.handleRemoval();
}
@Override
public Collection<Class<? extends ThingHandlerService>> getServices() {
return Collections.singleton(MyQDiscoveryService.class);