Accessing Liferay Web Services from other application

LR BEGINNER, modified 9 Years ago. New Member Posts: 24 Join Date: 7/21/16 Recent Posts
Hi All,

I'm trying to access Liferay Web Services from other application, but being prompt of this error:
XMLHttpRequest cannot load http://localhost:8080/api/jsonws/guestbook-portlet.guestbook/get-guestbooks/group-id/20182. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

I tried to access the liferay web services from my other application using this URL below:
private liferaySvcUrl = 'http://localhost:8080/api/jsonws/guestbook-portlet.guestbook/get-guestbooks/group-id/20182';

I had also implemented CORSFilter as per suggested in this blog below. I'm not sure whether i'm missing something.
https://web.liferay.com/community/dev.life/previous/-/asset_publisher/2wvNGOKWjJYi/content/20140923-tomas-polesovsky-securing-remote-json-web-services?redirect=https%3A%2F%2Fwww.liferay.com%2Fcommunity%2Fdev.life%2Fprevious%3Fp_p_id%3D101_INSTANCE_2wvNGOKWjJYi%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-2%26p_p_col_pos%3D3%26p_p_col_count%3D5&_ga=1.81035991.172414139.1487411093

Any advise would be great. Thanks.
thumbnail
Jagan Mohan Jayaraman, modified 9 Years ago. New Member Posts: 10 Join Date: 2/19/17 Recent Posts
Hi,

Have you checked this existing thread?

https://web.liferay.com/community/forums/-/message_boards/view_message/70107361

TTFN,
Jagan.
LR BEGINNER, modified 8 Years ago. New Member Posts: 24 Join Date: 7/21/16 Recent Posts
Hi Jagan,

Thanks for the reply. I can access the liferay web services now from other application using CORS. After successfully login to liferay, everytime i need to parse in the authentication string to call liferay web services. Is there any secure way to do this? How can i retrieve the token after successful login to liferay? Thanks.

authString = 'Basic ' + btoa(email + ':' + password);
headers.append('Authorization', this.authString);