1

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I was not able to add header using :- exchange.getIn().setHeader("Authorization", token); "Bearer" was not needed.
Yeah, the authorization type is most of the times not required, here is a discussion about it: security.stackexchange.com/a/120244
Okay. Thanks @burki for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.