Skip to content

Commit

Permalink
fixes networknt#583 Success result is returned even light-oauth2 retu…
Browse files Browse the repository at this point in the history
…rns an error message (networknt#585)
  • Loading branch information
stevehu authored Jul 20, 2019
1 parent 76f2095 commit fcef5dd
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,11 @@ private static Result<TokenResponse> handleResponse(ContentType contentType, Str
}
if (responseBody != null && responseBody.length() > 0) {
tokenResponse = Config.getInstance().getMapper().readValue(responseBody, TokenResponse.class);
if(tokenResponse != null) {
// sometimes, the token response contains an error status instead of the access token.
if(tokenResponse != null && tokenResponse.getAccessToken() != null) {
result = Success.of(tokenResponse);
} else {
result = Failure.of(new Status(GET_TOKEN_ERROR, responseBody));
result = Failure.of(new Status(tokenResponse.getStatusCode(), tokenResponse.getCode(), tokenResponse.getMessage(), tokenResponse.getDescription(), tokenResponse.getSeverity()));
}
} else {
result = Failure.of(new Status(GET_TOKEN_ERROR, "no auth server response"));
Expand Down

0 comments on commit fcef5dd

Please sign in to comment.