Foren
invoking authenticated json web services
Víctor Sáez, geändert vor 7 Jahren.
invoking authenticated json web services
New Member Beiträge: 9 Beitrittsdatum: 10.03.15 Neueste Beiträge
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, geändert vor 7 Jahren.
RE: invoking authenticated json web services
Regular Member Beiträge: 127 Beitrittsdatum: 16.09.19 Neueste Beiträge
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, geändert vor 7 Jahren.
RE: invoking authenticated json web services
New Member Beiträge: 9 Beitrittsdatum: 10.03.15 Neueste Beiträge
Ups. That was the problem. My screenName is test instead of test@liferay.com
Thanks very much
Thanks very much