我正在嘗試做一些相對簡單的事情。我有一個接收 oauth 令牌的請求,(Bearer asdf22324...)我需要將其傳遞給我的 feign 客戶端,以便能夠使用相同的令牌請求另一個服務。有可能這樣做嗎?有什么想法/例子嗎?我試過這樣:@PostMapping("/login")
ResponseEntity<Void> loginUser(@RequestHeader("Authorization") String authHeader);但是 authHeader 總是空的......我也嘗試了攔截器,但我不確定它會如何影響其他人(也不知道如何調用它)。Feign Client - 動態(tài)授權標頭想法?
1 回答

冉冉說
TA貢獻1877條經(jīng)驗 獲得超1個贊
也許您可以嘗試實現(xiàn)Filter(say TokenFilter) 并在其中讀取Authorization標頭HttpServletRequest并提取令牌。
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>
添加回答
舉報
0/150
提交
取消