且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Apache Camel 中使用 Oauth Header 调用 REST API?

更新时间:2021-11-14 22:09:40

您可以在处理器中设置 Authorization 标头,然后使用 .to()

You can set the Authorization header in your processor and then send the REST request with .to()

public void process(Exchange exchange) throws Exception {
    String token = //your logic to get the token
    exchange.getIn().setHeader("Authorization", "Bearer " + token)
}

.to("your/rest/endpoint") 

Camel 自动将消息头复制到外发消息上.

Camel automatically copies over the message headers onto the outgoing message.