Foros de discusión
invoking authenticated json web services
Víctor Sáez, modificado hace 7 años.
invoking authenticated json web services
New Member Mensajes: 9 Fecha de incorporación: 10/03/15 Mensajes recientes
I have the following code :
// url has the value of : http://localhost:8081/api/jsonws/user/get-user-by-screen-name/company-id/20154/screen-name/test@liferay.com
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
String credentials = "test@liferay.com:test";
BASE64Encoder encoder = new BASE64Encoder();
String b64 = encoder.encode(credentials.getBytes());
HttpGet request = new HttpGet(url);
request.addHeader("Authorization: Basic", b64);
request.addHeader("content-type", "application/json");
HttpResponse result = httpClient.execute(request);
String json = EntityUtils.toString(result.getEntity(), "UTF-8");
The answer from the server is {"exception":"java.lang.SecurityException","message":"Authenticated access required"}
Any idea?
Thanks very much in advance
It seems that authentication is not working acdeses the service
// url has the value of : http://localhost:8081/api/jsonws/user/get-user-by-screen-name/company-id/20154/screen-name/test@liferay.com
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
String credentials = "test@liferay.com:test";
BASE64Encoder encoder = new BASE64Encoder();
String b64 = encoder.encode(credentials.getBytes());
HttpGet request = new HttpGet(url);
request.addHeader("Authorization: Basic", b64);
request.addHeader("content-type", "application/json");
HttpResponse result = httpClient.execute(request);
String json = EntityUtils.toString(result.getEntity(), "UTF-8");
The answer from the server is {"exception":"java.lang.SecurityException","message":"Authenticated access required"}
Any idea?
Thanks very much in advance
It seems that authentication is not working acdeses the service
Anonymous Anonymous, modificado hace 7 años.
RE: invoking authenticated json web services
Regular Member Mensajes: 127 Fecha de incorporación: 16/09/19 Mensajes recientes
Hi ,
Is your Screen Name is :test@liferay.com ?
"url has the value of : http://localhost:8081/api/jsonws/user/get-user-by-screen-name/company-id/20154/screen-name/test@liferay.com"
in my case :
http://localhost:8080/api/jsonws/user/get-user-by-screen-name/company-id/10154/screen-name/joebloggs
An its working fine .
Regards,
Enayath
Is your Screen Name is :test@liferay.com ?
"url has the value of : http://localhost:8081/api/jsonws/user/get-user-by-screen-name/company-id/20154/screen-name/test@liferay.com"
in my case :
http://localhost:8080/api/jsonws/user/get-user-by-screen-name/company-id/10154/screen-name/joebloggs
An its working fine .
Regards,
Enayath
Víctor Sáez, modificado hace 7 años.
RE: invoking authenticated json web services
New Member Mensajes: 9 Fecha de incorporación: 10/03/15 Mensajes recientes
Ups. That was the problem. My screenName is test instead of test@liferay.com
Thanks very much
Thanks very much