I am working through the oAuth2 sample code and have hit a Restlet issue that
has stymied me for a while. Following the sample code, I have:
HttpOAuthHelper.setAuthPageTemplate("authorize.html", getContext());
However, when AuthPageServerResource.getPage() is called the following code
is unable to find "authorize.html":
Configuration config = new Configuration();
ContextTemplateLoader ctl = new ContextTemplateLoader(getContext(),
"clap:///");
config.setTemplateLoader(ctl);
getLogger().fine("loading: " + authPage);
TemplateRepresentation result = new TemplateRepresentation(authPage,
config, MediaType.TEXT_HTML);
Specifically, result.template is null. The message that I see is:
WARNING: Unable to get the template authorize.html. Error message: Template
authorize.html not found.
The first problem I fixed was adding the CLAP protocol. My web.xml file
had:
<context-param>
<param-name>org.restlet.clients</param-name>
<param-value>HTTP HTTPS CLAP </param-value>
</context-param>
but that didn't seem to be enough, so in MyOauthServer.createInboundRoot()
method, I added:
this.getConnectorService().getClientProtocols().add(Protocol.CLAP); //
For Freemarker
this.getContext().getClientDispatcher().getProtocols().add(Protocol.CLAP);
// For Freemarker another attempt
This fixed the error message "FINE: The protocol used by this request is not
declared in the application's connector service. Please update the list of
client connectors used by your application and restart it." but did not
solve the null template problem.
It seems that the getPage() is trying to load a "class" of type "html" from
the top-level directory of my war file. And that is where I have
authorize.html. I also put it in the WEB-INF directory. In addition, since
MyOauthServer is setup in my web.xml file as:
<servlet>
<servlet-name>AuthServer</servlet-name>
<servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
<init-param>
<param-name>org.restlet.application</param-name>
<param-value>com.fourspires.oauth.server.MyOauthServer</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>AuthServer</servlet-name>
<url-pattern>/oauth/*</url-pattern>
</servlet-mapping>
I also put an authorize.html at "war"/oauth/authorize.html and
"war"/web-inf/oauth/authorize.html.
But alas, none of these work. Where do I have to place the authorize.html
file so that it can be loaded by the ContextTemplateLoader?
Note: I am running 2.2 GAE Edition.
Thanks so much!
RB
--
View this message in context:
http://restlet-discuss.1400322.n2.nabble.com/OAuth2-How-to-resolve-Unable-to-get-the-template-authorize-html-tp7575959.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2964942