我正在尝试通过伪客户端端口而不是oauth服务器端口屏蔽oauth /令牌生成。我已经添加了请求拦截器。
但是当我尝试生成令牌时,得到的406不可接受,如下所示:
有人可以发布解决方案吗?
public class UserFeignClientInterceptor implements RequestInterceptor {
private static final String AUTHORIZATION_HEADER = "Authorization";
private static final String BEARER_TOKEN_TYPE = "Bearer";
@Override
public void apply(RequestTemplate template) {
SecurityContext securityContext = SecurityContextHolder.getContext();
Authentication authentication = securityContext.getAuthentication();
if (authentication != null && authentication.getDetails() instanceof OAuth2AuthenticationDetails) {
OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails) authentication.getDetails();
System.out.println("details " + details.getRemoteAddress());
System.out.println("details " + details.getSessionId());
System.out.println("details " + details.getTokenType());
System.out.println("details " + details.getTokenValue());
System.out.println("details " + details.getDecodedDetails());
template.header(AUTHORIZATION_HEADER, String.format("%s %s", BEARER_TOKEN_TYPE, details.getTokenValue()));
}
}
}