OAuth2 토큰 타입이 없을 때 Authorization 헤더에 Bearer 접두어 미부착

accessToken.getTokenType()이 비어있으면 Bearer 접두어 없이 토큰 값만
헤더에 설정하도록 setAuthHeaders를 수정하고, OAuth2AccessTokenVO의
tokenType은 BEARER_TYPE과 대소문자 무관하게 일치할 때만 상수로 정규화한다.
This commit is contained in:
curry772
2026-07-21 15:01:54 +09:00
parent 98d815e659
commit d13278c374
2 changed files with 19 additions and 18 deletions
@@ -862,26 +862,24 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
} }
} }
protected void setAuthHeaders(HttpUriRequestBase method, String authorization) throws Exception { protected void setAuthHeaders(HttpUriRequestBase method, String authorization, String authorizationHeaderName)
method.setHeader("Authorization", throws Exception {
String.format("%s", authorization)); if (StringUtils.isEmpty(authorizationHeaderName))
}
protected void setAuthHeaders(HttpUriRequestBase method, String authorization, String authorizationHeaderName) throws Exception {
if(StringUtils.isEmpty(authorizationHeaderName))
authorizationHeaderName = "Authorization"; authorizationHeaderName = "Authorization";
method.setHeader(authorizationHeaderName,
String.format("%s", authorization)); method.setHeader(authorizationHeaderName, String.format("%s", authorization));
} }
protected void setAuthHeaders(HttpUriRequestBase method, OAuth2AccessTokenVO accessToken) throws Exception { protected void setAuthHeaders(HttpUriRequestBase method, OAuth2AccessTokenVO accessToken,
method.setHeader("Authorization", String authorizationHeaderName) throws Exception {
String.format("%s %s", AccessTokenVO.BEARER_TYPE, accessToken.getAccessToken())); if (StringUtils.isEmpty(authorizationHeaderName))
} authorizationHeaderName = "Authorization";
protected void setAuthHeaders(HttpUriRequestBase method, OAuth2AccessTokenVO accessToken, String authorizationHeaderName) throws Exception { if (StringUtils.isEmpty(accessToken.getTokenType()))
method.setHeader(authorizationHeaderName, method.setHeader(authorizationHeaderName, String.format("%s", accessToken.getAccessToken()));
String.format("%s %s", AccessTokenVO.BEARER_TYPE, accessToken.getAccessToken())); else
method.setHeader(authorizationHeaderName,
String.format("%s %s", AccessTokenVO.BEARER_TYPE, accessToken.getAccessToken()));
} }
private boolean checkTokenRetry(byte[] responseMessage, String tokenErrorCodeKey, String tokenErrorCodeValues, private boolean checkTokenRetry(byte[] responseMessage, String tokenErrorCodeKey, String tokenErrorCodeValues,
@@ -56,7 +56,10 @@ public class OAuth2AccessTokenVO implements AccessTokenVO, Serializable
} }
public void setTokenType(String tokenType) { public void setTokenType(String tokenType) {
this.tokenType = tokenType; if(tokenType.equalsIgnoreCase(BEARER_TYPE))
this.tokenType = BEARER_TYPE;
else
this.tokenType = tokenType;
} }
public long getExpiresIn() { public long getExpiresIn() {