Forums de discussion
invoking authenticated json web services
Víctor Sáez, modifié il y a 7 années.
invoking authenticated json web services
New Member Publications: 9 Date d'inscription: 10/03/15 Publications récentes
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, modifié il y a 7 années.
RE: invoking authenticated json web services
Regular Member Publications: 127 Date d'inscription: 16/09/19 Publications récentes
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, modifié il y a 7 années.
RE: invoking authenticated json web services
New Member Publications: 9 Date d'inscription: 10/03/15 Publications récentes
Ups. That was the problem. My screenName is test instead of test@liferay.com
Thanks very much
Thanks very much