I am trying to do something relatively simple.
I have a request that receives an oauth token (Bearer asdf22324...)
I need it to pass it to my feign client to be able to request another service using the same token.
Is it possible to do that? Any ideas/examples?
I have tried this way:
@PostMapping("/login")
ResponseEntity<Void> loginUser(@RequestHeader("Authorization") String authHeader);
But authHeader is always empty...
I also tried the interceptor, but I'm not sure how it would affect others (and not sure how to invoke it either).
Feign Client - Dynamic Authorization Header
Ideas?
May be you can try implementing the Filter
(say TokenFilter
) and inside it you can read the Authorization
header from the HttpServletRequest
and extract the token.
String authTokenHeader = request.getHeader("Authorization");
// parse the token
// there can be type of token passed. So you may need to take the substring after the type and the whitespace. Eg: Bearer <TOKEN>