Catch json parsing errors when getting login token. ()

Fixes 

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
This commit is contained in:
Dan Cunningham 2022-07-29 10:06:48 -07:00 committed by GitHub
parent b20180fa19
commit d5b657c6fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -342,12 +342,16 @@ public class MyQAccountHandler extends BaseBridgeHandler implements AccessTokenR
ContentResponse tokenResponse = getLoginToken(location, codeVerifier);
String loginToken = tokenResponse.getContentAsString();
AccessTokenResponse accessTokenResponse = gsonLowerCase.fromJson(loginToken, AccessTokenResponse.class);
if (accessTokenResponse == null) {
throw new MyQAuthenticationException("Could not parse token response");
try {
AccessTokenResponse accessTokenResponse = gsonLowerCase.fromJson(loginToken, AccessTokenResponse.class);
if (accessTokenResponse == null) {
throw new MyQAuthenticationException("Could not parse token response");
}
getOAuthService().importAccessTokenResponse(accessTokenResponse);
return accessTokenResponse;
} catch (JsonSyntaxException e) {
throw new MyQCommunicationException("Invalid Token Response " + loginToken);
}
getOAuthService().importAccessTokenResponse(accessTokenResponse);
return accessTokenResponse;
} catch (IOException | ExecutionException | TimeoutException | OAuthException | URISyntaxException e) {
throw new MyQCommunicationException(e.getMessage());
}