Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Accessing Liferay Web Services from other application
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.
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.
Hi,
Have you checked this existing thread?
https://web.liferay.com/community/forums/-/message_boards/view_message/70107361
TTFN,
Jagan.
Have you checked this existing thread?
https://web.liferay.com/community/forums/-/message_boards/view_message/70107361
TTFN,
Jagan.
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);
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);