[ecowatt] Remove the access token when the thing is removed (#14934)

Related to #14818

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2023-05-05 22:35:09 +02:00 committed by GitHub
parent 4e8e39cd9f
commit 831a7af2c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -116,6 +116,15 @@ public class EcowattHandler extends BaseThingHandler {
}
}
@Override
public void handleRemoval() {
EcowattRestApi localApi = api;
if (localApi != null) {
localApi.deleteServiceAndAccessToken();
}
super.handleRemoval();
}
/**
* Schedule the next update of channels.
*

View File

@ -140,4 +140,8 @@ public class EcowattRestApi {
public void dispose() {
oAuthFactory.ungetOAuthService(authServiceHandle);
}
public void deleteServiceAndAccessToken() {
oAuthFactory.deleteServiceAndAccessToken(authServiceHandle);
}
}