Liferay will support our API and resolve any issues and answer any questions having to do with the API itself or any other part of Liferay's software. Issues and questions regarding custom development may be handled by our Global Services team or by the developer of those customizations.
If a customer is using JSON authentication for a custom portlet, the Liferay API in regards to the service call must be included. Otherwise, users may have to authenticate their sign in credentials a second time. Because this article involves a custom portlet, some of the information should be adapted for specific environments.
Resolution
Before compiling the portlet, modify the portlet's view.jsp accordingly from:
code>
function callService2()
{
Liferay.Service('/api/jsonws/[custom portlet name].thing/find-all-things',
function(obj) {
console.log(obj);
}
);
}
to
code>
function callService2()
{
Liferay.Service('/[custom portlet name].thing/find-all-things',
function(obj) {
console.log(obj);
}
);
}
- Compile the custom portlet.
- Start a Liferay bundle.
- Use all default options and leave Hypersonic as the default database.
- Stop the application server.
- Create a newportal-ext.propertieswith the following properties:
code> auth.token.check.enabled=false json.service.auth.token.enabled=false jsonws.web.service.public.methods=get*,has*,is*,save*,xx*,remove*,update* json.service.public.methods=get*,has*,is*,save*,xx*,remove*,update*
- Place the
portal-ext.propertiesin the same directory withportal-setup-wizard.properties - Restart the portal.
- Deploy the custom portlet.
- Open a new browser window that does not have any session information on cookies. For Chrome users, use the Incognito window feature. (All the examples will be using Chrome. For Firefox and Internet Explorer users, the corresponding features are Private Windows and InPrivate Browsing, respectively.)
- Click Go to > My Private Pages
- Create a private page named Hello World. The resulting URL will be:
http://localhost:8080/group/[username]/hello-world - Add the custom portlet to that page.
- Close the browser.
- Open a new Incognito Chrome window with two tabs:
http://localhost:8080/http://localhost:8080/[custom portlet name]/api/jsonws
- Do not log in yet. At this point, users will be prompted for authentication on the second browser tab.
- Close the second tab.
- Log in to the portal on the first browser tab.
- Open a new tab to this URL:
http://localhost:8080/[custom portlet name]/api/jsonws. Notice that the user is authenticated and does not need to log in again.
Additional Information
JSON Web Services (Liferay Portal 6.1 Developers Guide)