Java Jersey glassfish fix renewing OAuth-Accesstoken #14734 (#14735)

This commit is contained in:
sbilz
2023-02-25 15:01:33 +01:00
committed by GitHub
parent 5c9999b7cf
commit f4e53db8cf
9 changed files with 34 additions and 25 deletions

View File

@@ -1165,8 +1165,10 @@ public class ApiClient extends JavaTimeFormatter {
try {
response = sendRequest(method, invocationBuilder, entity);
final int statusCode = response.getStatusInfo().getStatusCode();
// If OAuth is used and a status 401 is received, renew the access token and retry the request
if (response.getStatusInfo() == Status.UNAUTHORIZED) {
if (statusCode == Status.UNAUTHORIZED.getStatusCode()) {
for (String authName : authNames) {
Authentication authentication = authentications.get(authName);
if (authentication instanceof OAuth) {
@@ -1181,10 +1183,9 @@ public class ApiClient extends JavaTimeFormatter {
}
}
int statusCode = response.getStatusInfo().getStatusCode();
Map<String, List<String>> responseHeaders = buildResponseHeaders(response);
if (response.getStatusInfo() == Status.NO_CONTENT) {
if (statusCode == Status.NO_CONTENT.getStatusCode()) {
return new ApiResponse<T>(statusCode, responseHeaders);
} else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) {
if (returnType == null) {