1
votes

I am consuming an API with OAuth1.0 authorization. I want to make call to that API with the authorization Oauth header:-
I have created the authorization header from the token/key received from the server using- (ConsumerKey,keyalias and password) and want to send back the token or the OAuth header with the call.

I have did all these things in a Processor(Class implementing Camel Processor) and now want to do:-

  1. Either call the rest API with this Oauth header(of type String) in the processor itself.
  2. Else send this header in exchange and get this value in camel's to() endpoint and then in it call the REST API.

Thing is i just want to make rest a call in processor with Oauth header. And then if possible try to access the header in to() endpoint and make the call.

1

1 Answers

1
votes

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 automatically copies over the message headers onto the outgoing message.