Foros de discusión

Problem in acces json web services liferay 6.2

Abhijeet Naukharkar, modificado hace 8 años.

Problem in acces json web services liferay 6.2

Junior Member Mensajes: 70 Fecha de incorporación: 27/03/15 Mensajes recientes
Hi Friends,
I am facing problem while access json web services liferay 6.2 .
I use the following URL in Liferay 6.1
http://localhost:8080/LiferayJSONWebservices-portlet/api/jsonws/employee/get-employee/emplyee-id/1
It works properly and prompt for the admin credential.

Now I made following change to for the URL for Liferay 6.2
1. Add following properties in portal-ext.properties
json.service.auth.token.hosts.allowed=127.0.0.1,SERVER_IP
json.service.auth.token.enabled=false
jsonws.web.service.public.methods=*
jsonws.servlet.hosts.allowed=127.0.0.1,SERVER_IP


2. And apply following URL to Access JSON web Service
http://test@liferay.com:test@localhost:8080/api/jsonws/LiferayJSONWebservices-portlet.employee/get-employee/emplyee-id/1

The above configuration gives following error.
{"exception":"Authenticated access required"}

I also refer the last article about preemptive authentication from https://www.liferay.com/community/forums/-/message_boards/message/51162370
But I didn't get idea where the changes made from the above article.
I want to implement secure web service access in Liferay 6.2. Please Suggest me proper configuration.
thumbnail
Denis Signoretto, modificado hace 8 años.

RE: Problem in acces json web services liferay 6.2

Expert Mensajes: 375 Fecha de incorporación: 21/04/09 Mensajes recientes
Hi Abhijeet,

I've seen you are authenticating on Liferay by email address.
In your example you are using basing autentication passing credentials (email:password) in the URL.
According to RFC 3986 you should encode @ character using %40.

Do you have the same issue invoking the service from jsonws console (http://localhost:8080/api/jsonws) as authenticated user ?

Bye,
Denis.
Abhijeet Naukharkar, modificado hace 8 años.

RE: Problem in acces json web services liferay 6.2

Junior Member Mensajes: 70 Fecha de incorporación: 27/03/15 Mensajes recientes
No, I don't get issue invoking the service from jsonws console as authenticated user.
thumbnail
Raju oukanti, modificado hace 8 años.

RE: Problem in acces json web services liferay 6.2

Regular Member Mensajes: 143 Fecha de incorporación: 21/02/12 Mensajes recientes
Hi,

See the following code will help to you :

String userEmailId="test@liferay.com";
String password="test";
String credentails=userEmailId+":"+password;
byte[] bytes = credentails.getBytes();
credentails=Base64.encode(bytes);
String jsonData=Request.Get(webServiceUrl).addHeader("Authorization", "Basic "+credentails).execute().returnContent().asString();



Thanks,
Raju