You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Rafael Soares <ra...@gmail.com> on 2017/01/18 12:49:29 UTC

Re: OAuth & Camel

Hi Arpit!

What exactly do you need? Are you implementing a secured Restfull service
on your route or invoking a secured remote service from your route?
Recently I faced the similar scenario where I need to invoke a secured
restful service from my route (I was the service client).

I also did a long search on the internet looking for some way (some camel
component supporting oAuth protocol) to implement the oAuth handshake.
Well, at the end of the day I've found two paths:


   - use Apache CXFJAX-RS oAuth support [1]
   - use the camel-http4 [2] component to get the oAuth token by hand...


Well, I tried the first path with CXF, but gave up due my lack of
experience with apache cxf. IMHO the documentation is a bit complicated for
some scenarios (I just wanted to request a remote service using oauth :-\).
Well I hope CXF expert guys can comment on this.

The 2nd path worked better for me. At the time I've also found this thread
[3] suggest a similar approach. But instead of using camel-http4 it suggest
the use off OLTU project [4] from a camel bean/processor.

In my case I decided to use a raw http request in order to get my auth
toker. Basically you have to invoke the oAuth service passing your
credentials (eg: client secret) and if it is successfully authorized store
it your auth token in your Camel exchange Header. Then you can your that
token alongside your camel route/context to invoke secured remote services.

See a snippet of my route:

https://gist.github.com/rafaeltuelho/4d2449ac9b709fd29d79fa89acd8b48b

I hope this can help you.

[1] http://cxf.apache.org/docs/jax-rs-oauth.html
[2] http://camel.apache.org/http4.html
[3]
http://camel.465427.n5.nabble.com/Need-help-with-OAuth-for-Camel-Https-Client-td5757513.html
[4]
https://cwiki.apache.org/confluence/display/OLTU/OAuth+2.0+Client+Quickstart

________________________
Rafael Torres Coelho Soares

On Mon, Jan 16, 2017 at 7:53 PM, Goyal, Arpit <ar...@sap.com> wrote:

> Hello,
>
> Searched and found article where it is specified Camel-http and http4
> doesn't support OAuth.
> http://camel.465427.n5.nabble.com/Need-help-with-OAuth-for-
> Camel-Https-Client-td5757513.html#a5757531
>
> Also, other unanswered questions
> http://camel.465427.n5.nabble.com/camel-oauth-
> implementation-td5772676.html
> http://camel.465427.n5.nabble.com/Restlet-with-oauth-td5774366.html
>
> So this still holds true - no one has been able to get this working yet
> with Camel (apart from Google API)?
>
> Regards,
> Arpit.
>

RE: OAuth & Camel

Posted by "Goyal, Arpit" <ar...@sap.com>.
Hi Rafael,

Thank you so much for the pointers, I will try it out definitely and let you know.

My use-case is:
- Custom Trust Store with camel-http4
- OAuth token to be sent with header
 --- but this is with SAML Bearer Token, so there is an additional complexity. 

Definitely will come back to you with my snippet of code if I get it working.  

Regards,
Arpit.

-----Original Message-----
From: Rafael Soares [mailto:rafaelcba@gmail.com] 
Sent: Wednesday, January 18, 2017 4:49 AM
To: users@camel.apache.org
Subject: Re: OAuth & Camel

Hi Arpit!

What exactly do you need? Are you implementing a secured Restfull service
on your route or invoking a secured remote service from your route?
Recently I faced the similar scenario where I need to invoke a secured
restful service from my route (I was the service client).

I also did a long search on the internet looking for some way (some camel
component supporting oAuth protocol) to implement the oAuth handshake.
Well, at the end of the day I've found two paths:


   - use Apache CXFJAX-RS oAuth support [1]
   - use the camel-http4 [2] component to get the oAuth token by hand...


Well, I tried the first path with CXF, but gave up due my lack of
experience with apache cxf. IMHO the documentation is a bit complicated for
some scenarios (I just wanted to request a remote service using oauth :-\).
Well I hope CXF expert guys can comment on this.

The 2nd path worked better for me. At the time I've also found this thread
[3] suggest a similar approach. But instead of using camel-http4 it suggest
the use off OLTU project [4] from a camel bean/processor.

In my case I decided to use a raw http request in order to get my auth
toker. Basically you have to invoke the oAuth service passing your
credentials (eg: client secret) and if it is successfully authorized store
it your auth token in your Camel exchange Header. Then you can your that
token alongside your camel route/context to invoke secured remote services.

See a snippet of my route:

https://gist.github.com/rafaeltuelho/4d2449ac9b709fd29d79fa89acd8b48b

I hope this can help you.

[1] http://cxf.apache.org/docs/jax-rs-oauth.html
[2] http://camel.apache.org/http4.html
[3]
http://camel.465427.n5.nabble.com/Need-help-with-OAuth-for-Camel-Https-Client-td5757513.html
[4]
https://cwiki.apache.org/confluence/display/OLTU/OAuth+2.0+Client+Quickstart

________________________
Rafael Torres Coelho Soares

On Mon, Jan 16, 2017 at 7:53 PM, Goyal, Arpit <ar...@sap.com> wrote:

> Hello,
>
> Searched and found article where it is specified Camel-http and http4
> doesn't support OAuth.
> http://camel.465427.n5.nabble.com/Need-help-with-OAuth-for-
> Camel-Https-Client-td5757513.html#a5757531
>
> Also, other unanswered questions
> http://camel.465427.n5.nabble.com/camel-oauth-
> implementation-td5772676.html
> http://camel.465427.n5.nabble.com/Restlet-with-oauth-td5774366.html
>
> So this still holds true - no one has been able to get this working yet
> with Camel (apart from Google API)?
>
> Regards,
> Arpit.
>