Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jersey-dev] debugging ClientRequestFilter with token


Using the client filter looks ok, but you can set the header to the request directly:

ClientBuilder.newClient().target().request().header(HttpHeaders.AUTHORIZATION, ...)

Debugging the headers is harder. It would be good to see what it comes to the server side, so you can use a @PreMatching filter and put the breakpoint there.
If the server side is not JAX-RS endpoint, you can use WireShark (pcap) to sniff the HTTP transport.
If you feel like debugging Jersey code, the good point is always ServerRuntime#process:

Try to compare what comes from CURL and what from the Jersey client to the server side.

-- Jan

On 02.12.2020 20:48, Colin Williams wrote:

I’m trying to resolve an issue with using a token. Via curl I make a
request like

curl -H 'Authorization: Bearer d2a09f52-fd70-40be-a3d4-2d41cb549d5d';!!GqivPVa7Brio!P3AaszBZQyjVXPwEj_K3UXwNElyb7EoDqyjUBcaJItsDxS84zXaysPe__Sl5dzGY$

And the response is OK. Then I try to do the same using a
ClientRequestFilter and client. I receive an error code. I tried to
look in the debugger to see what the request header looks like. I
haven’t been able to find it, but maybe I should set the breakpoint

Then I’m looking for advice regarding what I might be doing wrong, or
where I might find the request header via debugger.

class BearerTokenFilter implements ClientRequestFilter {
   private final String bearerToken;
   public BearerTokenFilter(String bearerToken){
    this.bearerToken = bearerToken;
  public static final String FILTER_HEADER_KEY = "Authorization";

   public void filter(ClientRequestContext requestContext) throws IOException {
     String bearerTokenString = "Bearer " + bearerToken;


Best Regards,

Colin Williams
jersey-dev mailing list
To unsubscribe from this list, visit;!!GqivPVa7Brio!P3AaszBZQyjVXPwEj_K3UXwNElyb7EoDqyjUBcaJItsDxS84zXaysPe__QGL3RYB$

Back to the top