[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jersey-dev] debugging ClientRequestFilter with token
|
Hello,
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'
https://service-endpoint/api/v1/namespaces/default/deployments
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
elsewhere.
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";
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
String bearerTokenString = "Bearer " + bearerToken;
requestContext.getHeaders().add(FILTER_HEADER_KEY,bearerTokenString);
}
builder.register(new
BearerTokenFilter(this.bearerToken)).build().property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND,
true)
Best Regards,
Colin Williams