mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[ecobee] Improve handling of invalid_grant error (#8857)
Signed-off-by: Mark Hilbush <mark@hilbush.com>
This commit is contained in:
parent
472c0fd960
commit
a84222cf5e
@ -170,13 +170,24 @@ public class EcobeeApi implements AccessTokenRefreshListener {
|
||||
logger.info("API: The Ecobee authorization process threw an exception", e);
|
||||
ecobeeAuth.setState(EcobeeAuthState.NEED_PIN);
|
||||
} catch (OAuthResponseException e) {
|
||||
logger.info("API: Exception getting access token: error='{}', description='{}'", e.getError(),
|
||||
e.getErrorDescription());
|
||||
// How to handle the possible error codes?
|
||||
handleOAuthException(e);
|
||||
}
|
||||
return isAuthorized;
|
||||
}
|
||||
|
||||
private void handleOAuthException(OAuthResponseException e) {
|
||||
if ("invalid_grant".equalsIgnoreCase(e.getError())) {
|
||||
// Usually indicates that the refresh token is no longer valid and will require reauthorization
|
||||
logger.warn("API: Received 'invalid_grant' error response. Please reauthorize application with Ecobee");
|
||||
deleteOAuthClientService();
|
||||
createOAuthClientService();
|
||||
} else {
|
||||
// Other errors may not require reauthorization and/or may not apply
|
||||
logger.warn("API: Exception getting access token: error='{}', description='{}'", e.getError(),
|
||||
e.getErrorDescription());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccessTokenResponse(AccessTokenResponse accessTokenResponse) {
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user