You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by AnitaJ <ja...@gmail.com> on 2011/10/10 19:05:23 UTC

Need help with Camel OAuth

Hi, 

I am not sure if this the right forum, I am hoping it is.... Here is my
question:

I am trying to follow the tutorial at this link: 
http://camel.apache.org/tutorial-oauth.html Camel OAuth Tutorial 

I was able to get it started, but I am stuck at the point where I click on
the link to authorize the application. I am always getting a 404.

The url that returns the 404 is \camel\authorize and \camel\* is mapped to
org.apache.camel.component.servlet.CamelHttpTransportServlet

I looked at the source code for CamelHttpTransportServlet and CamelServlet
and it looks fine to me. The only thing that I suspected was that maybe
there aren't any registered consumers. But since I am trying to run it
through google app engine, I was not really able to debug it any better.

Can someone give me any pointers on what could possibly be going wrong?

Thanks in advance for your help!!

-Anita

--
View this message in context: http://camel.465427.n5.nabble.com/Need-help-with-Camel-OAuth-tp4888875p4888875.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Need help with Camel OAuth

Posted by AnitaJ <ja...@gmail.com>.
Oh, I didn't quite expect to do all that.... (not to sound totally
ungrateful... I am, truly!)... but, I was under the (obviously mistaken)
impression that the example would work out of the box with minor tweaks :)

Thanks for your help Brian. I will give it a try and post an update asap :)



--
View this message in context: http://camel.465427.n5.nabble.com/Need-help-with-Camel-OAuth-tp4888875p4889461.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Need help with Camel OAuth

Posted by Brian Topping <to...@codehaus.org>.
Sorry Anita, I meant to specify the "jetty" component, although you will likely need the "gauth" as well.

On Oct 10, 2011, at 3:02 PM, Brian Topping wrote:

> I see, I didn't realize you were going exactly from the example.  
> 
> I ran into a couple of problems.  One was the accessibility of a java keystore file and setting up the password.  This was required for the HTTPS component of the Jetty server to function. That's not documented in this example page, and it did not seem to work to provide a non SSL address so the keystore was not required.
> 
> Please take a look at my routes.xml here and see if you can use the SSL setup in order to resolve that part first by adding the "gauth" bean configuration I have to your configuration.  If you still have problems, please provide some stack traces for further analysis.example
> 
>> <?xml version="1.0" encoding="UTF-8"?>
>> 
>> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>       xmlns:cxf="http://camel.apache.org/schema/cxf" xmlns:osgi="http://www.springframework.org/schema/osgi"
>>       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>>                           http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
>>                           http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
>>                           http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
>> 
>>    <cxf:rsServer id="rsServer" address="http://0.0.0.0:9090/batch"
>>                  serviceClass="net.example.component.sample.dbtest.ControllerService"/>
>> 
>>    <camelContext xmlns="http://camel.apache.org/schema/spring">
>>        <route id="control">
>>            <from uri="cxfrs:bean:rsServer"/>
>>            <to uri="log:net.example.controller.sample"/>
>>            <bean ref="controllerBean" method="doSomething"/>
>>        </route>
>>        <route id="youtubeOauth">
>>            <!--Route 1: A GET request to http://gauth.example.org/authorize will trigger the the OAuth-->
>>            <!--sequence of interactions. The gauth:authorize endpoint obtains an unauthorized request-->
>>            <!--token from Google and then redirects the user (browser) to a Google authorization page.            -->
>>            <from uri="jetty:https://0.0.0.0:8980/authorize"/>
>>            <to uri="gauth:authorize?callback=https://localhost:8980/handler&amp;scope=http://gdata.youtube.com"/>
>>        </route>
>>        <route id="youtubeUpgrade">
>>            <!--Route 2: Handle callback from Google. After the user granted access to Google Calendar-->
>>            <!--Google redirects the user to https://gauth.example.org:8443/handler (see callback) along-->
>>            <!--with an authorized request token. The gauth:access endpoint exchanges the authorized-->
>>            <!--request token against a long-lived access token.-->
>>            <from uri="jetty:https://0.0.0.0:8980/handler?sslKeyPassword=changeit"/>
>>            <to uri="gauth:upgrade"/>
>>            <process ref="oauthProcessBean"/>
>>        </route>
>>    </camelContext>
>> 
>>    <bean id="gauth" class="org.apache.camel.component.gae.auth.GAuthComponent">
>>        <!-- Google will display a warning message on the authorization page -->
>>        <property name="consumerKey" value="anonymous" />
>>        <property name="consumerSecret" value="anonymous" />
>>    </bean>
>> 
>> 
>>    <bean id="jetty" class="org.apache.camel.component.jetty.JettyHttpComponent">
>>        <property name="sslSocketConnectorProperties">
>>            <props>
>>                <prop key="password">changeit</prop>
>>                <prop key="keyPassword">changeit</prop>
>>                <property name="keystore" value="/home/topping/keystore"/>
>>            </props>
>>        </property>
>>    </bean>
>> 
>>    <bean id="controllerBean" class="net.example.component.sample.dbtest.TestBean">
>>        <property name="partyDao">
>>            <osgi:reference interface="net.example.component.dao.PartyDao"/>
>>        </property>
>>    </bean>
>> 
>>    <bean id="oauthProcessBean" class="net.example.component.sample.dbtest.OauthProcessorBean"/>
>> </beans>
>> 
>> 
> 
> 
> 
> On Oct 10, 2011, at 2:05 PM, AnitaJ wrote:
> 
>> Hi Brian,
>> 
>> The route is in the TutorialRouteBuilder class in this link: 
>> http://camel.apache.org/tutorial-oauth.html Camel OAuth tutorial 
>> 
>> <snip>
>> 
>> // Callback URL for sending back an authorized access token.
>> String encodedCallback =
>> URLEncoder.encode(String.format("https://%s.appspot.com/camel/handler",
>> application), "UTF-8");
>> 
>> // Google should issue an access token that is scoped to calendar feeds.
>> String encodedScope =
>> URLEncoder.encode("http://www.google.com/calendar/feeds/", "UTF-8");
>> 
>> // Route for obtaining an unauthorized request token from Google Accounts.
>> The
>> // response redirects the browser to an authorization page provided by
>> Google.
>> from("ghttp:///authorize")
>>           .to("gauth:authorize?callback=" + encodedCallback + "&scope=" +
>> encodedScope);
>> 
>> </snip>
>> 
>> 
>> 
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Need-help-with-Camel-OAuth-tp4888875p4889066.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>> 
> 
> 


Re: Need help with Camel OAuth

Posted by Brian Topping <to...@codehaus.org>.
I see, I didn't realize you were going exactly from the example.  

I ran into a couple of problems.  One was the accessibility of a java keystore file and setting up the password.  This was required for the HTTPS component of the Jetty server to function. That's not documented in this example page, and it did not seem to work to provide a non SSL address so the keystore was not required.

Please take a look at my routes.xml here and see if you can use the SSL setup in order to resolve that part first by adding the "gauth" bean configuration I have to your configuration.  If you still have problems, please provide some stack traces for further analysis.example

> <?xml version="1.0" encoding="UTF-8"?>
> 
> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xmlns:cxf="http://camel.apache.org/schema/cxf" xmlns:osgi="http://www.springframework.org/schema/osgi"
>        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>                            http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
>                            http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
>                            http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
> 
>     <cxf:rsServer id="rsServer" address="http://0.0.0.0:9090/batch"
>                   serviceClass="net.example.component.sample.dbtest.ControllerService"/>
> 
>     <camelContext xmlns="http://camel.apache.org/schema/spring">
>         <route id="control">
>             <from uri="cxfrs:bean:rsServer"/>
>             <to uri="log:net.example.controller.sample"/>
>             <bean ref="controllerBean" method="doSomething"/>
>         </route>
>         <route id="youtubeOauth">
>             <!--Route 1: A GET request to http://gauth.example.org/authorize will trigger the the OAuth-->
>             <!--sequence of interactions. The gauth:authorize endpoint obtains an unauthorized request-->
>             <!--token from Google and then redirects the user (browser) to a Google authorization page.            -->
>             <from uri="jetty:https://0.0.0.0:8980/authorize"/>
>             <to uri="gauth:authorize?callback=https://localhost:8980/handler&amp;scope=http://gdata.youtube.com"/>
>         </route>
>         <route id="youtubeUpgrade">
>             <!--Route 2: Handle callback from Google. After the user granted access to Google Calendar-->
>             <!--Google redirects the user to https://gauth.example.org:8443/handler (see callback) along-->
>             <!--with an authorized request token. The gauth:access endpoint exchanges the authorized-->
>             <!--request token against a long-lived access token.-->
>             <from uri="jetty:https://0.0.0.0:8980/handler?sslKeyPassword=changeit"/>
>             <to uri="gauth:upgrade"/>
>             <process ref="oauthProcessBean"/>
>         </route>
>     </camelContext>
> 
>     <bean id="gauth" class="org.apache.camel.component.gae.auth.GAuthComponent">
>         <!-- Google will display a warning message on the authorization page -->
>         <property name="consumerKey" value="anonymous" />
>         <property name="consumerSecret" value="anonymous" />
>     </bean>
> 
> 
>     <bean id="jetty" class="org.apache.camel.component.jetty.JettyHttpComponent">
>         <property name="sslSocketConnectorProperties">
>             <props>
>                 <prop key="password">changeit</prop>
>                 <prop key="keyPassword">changeit</prop>
>                 <property name="keystore" value="/home/topping/keystore"/>
>             </props>
>         </property>
>     </bean>
> 
>     <bean id="controllerBean" class="net.example.component.sample.dbtest.TestBean">
>         <property name="partyDao">
>             <osgi:reference interface="net.example.component.dao.PartyDao"/>
>         </property>
>     </bean>
> 
>     <bean id="oauthProcessBean" class="net.example.component.sample.dbtest.OauthProcessorBean"/>
> </beans>
> 
> 



On Oct 10, 2011, at 2:05 PM, AnitaJ wrote:

> Hi Brian,
> 
> The route is in the TutorialRouteBuilder class in this link: 
> http://camel.apache.org/tutorial-oauth.html Camel OAuth tutorial 
> 
> <snip>
> 
> // Callback URL for sending back an authorized access token.
> String encodedCallback =
> URLEncoder.encode(String.format("https://%s.appspot.com/camel/handler",
> application), "UTF-8");
> 
> // Google should issue an access token that is scoped to calendar feeds.
> String encodedScope =
> URLEncoder.encode("http://www.google.com/calendar/feeds/", "UTF-8");
> 
> // Route for obtaining an unauthorized request token from Google Accounts.
> The
> // response redirects the browser to an authorization page provided by
> Google.
> from("ghttp:///authorize")
>            .to("gauth:authorize?callback=" + encodedCallback + "&scope=" +
> encodedScope);
> 
> </snip>
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Need-help-with-Camel-OAuth-tp4888875p4889066.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
> 


Re: Need help with Camel OAuth

Posted by AnitaJ <ja...@gmail.com>.
Hi Brian,

The route is in the TutorialRouteBuilder class in this link: 
http://camel.apache.org/tutorial-oauth.html Camel OAuth tutorial 

<snip>

// Callback URL for sending back an authorized access token.
String encodedCallback =
URLEncoder.encode(String.format("https://%s.appspot.com/camel/handler",
application), "UTF-8");

// Google should issue an access token that is scoped to calendar feeds.
String encodedScope =
URLEncoder.encode("http://www.google.com/calendar/feeds/", "UTF-8");

// Route for obtaining an unauthorized request token from Google Accounts.
The
// response redirects the browser to an authorization page provided by
Google.
from("ghttp:///authorize")
            .to("gauth:authorize?callback=" + encodedCallback + "&scope=" +
encodedScope);

</snip>



--
View this message in context: http://camel.465427.n5.nabble.com/Need-help-with-Camel-OAuth-tp4888875p4889066.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Need help with Camel OAuth

Posted by Brian Topping <to...@codehaus.org>.
I just got done setting up Camel OAuth for the first time and would be happy to help.  If you've ever done OAuth before, you know how hard it can be.  Camel OAuth will mess with you in that case because it's so dirt simple!

Anyway, could you post your routes so myself (or others) could help you?

Cheers, Brian 
On Oct 10, 2011, at 1:05 PM, AnitaJ wrote:

> Hi, 
> 
> I am not sure if this the right forum, I am hoping it is.... Here is my
> question:
> 
> I am trying to follow the tutorial at this link: 
> http://camel.apache.org/tutorial-oauth.html Camel OAuth Tutorial 
> 
> I was able to get it started, but I am stuck at the point where I click on
> the link to authorize the application. I am always getting a 404.
> 
> The url that returns the 404 is \camel\authorize and \camel\* is mapped to
> org.apache.camel.component.servlet.CamelHttpTransportServlet
> 
> I looked at the source code for CamelHttpTransportServlet and CamelServlet
> and it looks fine to me. The only thing that I suspected was that maybe
> there aren't any registered consumers. But since I am trying to run it
> through google app engine, I was not really able to debug it any better.
> 
> Can someone give me any pointers on what could possibly be going wrong?
> 
> Thanks in advance for your help!!
> 
> -Anita
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Need-help-with-Camel-OAuth-tp4888875p4888875.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>