掲示板

invoking authenticated json web services

7年前 に Víctor Sáez によって更新されました。

invoking authenticated json web services

New Member 投稿: 9 参加年月日: 15/03/10 最新の投稿
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
7年前 に Anonymous Anonymous によって更新されました。

RE: invoking authenticated json web services

Regular Member 投稿: 127 参加年月日: 19/09/16 最新の投稿
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
7年前 に Víctor Sáez によって更新されました。

RE: invoking authenticated json web services

New Member 投稿: 9 参加年月日: 15/03/10 最新の投稿
Ups. That was the problem. My screenName is test instead of test@liferay.com

Thanks very much