Reputation: 99
We are making a Liferay API call via postman
...localhost:9080/api/jsonws/journalarticle/get-article/group-id/21333/article-id/21355
and that's the JSON result:
{"message": "Authenticated access required", "exception":"java.lang.SecurityException"}
We are using Liferay 6.2
Do we have to add an additional paramter (like p_auth) ?
Or maybe we are doing something completely wrong without knowing it ?
Upvotes: 1
Views: 3954
Reputation: 329
Add this above the method in your ServiceBaseImpl
class
@AccessControlled(guestAccessEnabled=true)
For Example: The URL to this below for mine was http://localhost:8080/[portlet-name]/api/jsonws/[service-entity]/get-remote-data
@AccessControlled(guestAccessEnabled=true)
public String getRemoteData() {
JSONObject obj = new JSONObject();
try {
obj.put("name", "sean");
obj.put("age", 39);
} catch (JSONException e) {
e.printStackTrace();
}
return obj.toString();
}
Upvotes: 1
Reputation: 931
Hi you don't need the p_auth from postman, just configure the tab authorization with a basic login using your liferay credential.
for more info for calling json service see the link https://www.liferay.com/it/web/tomas.polesovsky/blog/-/blogs/json-ws-security
Upvotes: 4