Foros de discusión

acces json web services liferay 6.2

Manuel Mancipe, modificado hace 10 años.

acces json web services liferay 6.2

New Member Mensajes: 24 Fecha de incorporación: 2/08/10 Mensajes recientes
Hi, I am trying to use the api http://localhost:8080/api/jsonws becasue i want to consume some services but I have some probem i got this message "Authenticated access required", I was investigating about the problem and we need to setup in the portal-ext.properties this sentence json.service.auth.token.hosts.allowed= but it does not working, I dont know why, can you help me? thanks. I am working with liferay 6.2 enterprise,
thumbnail
Pankaj Kathiriya, modificado hace 10 años.

RE: acces json web services liferay 6.2

Liferay Master Mensajes: 722 Fecha de incorporación: 5/08/10 Mensajes recientes
json.service.auth.token.enabled=false

Keep this property in portal-ext.properties
Manuel Mancipe, modificado hace 10 años.

RE: acces json web services liferay 6.2

New Member Mensajes: 24 Fecha de incorporación: 2/08/10 Mensajes recientes
Greetings to all

I implemented the solution http://test@liferay.com:test@localhost:8080/api/jsonws and work

Thank you,
thumbnail
meera prince, modificado hace 10 años.

RE: acces json web services liferay 6.2

Liferay Legend Mensajes: 1111 Fecha de incorporación: 8/02/11 Mensajes recientes
Hi
Use like this in Ajax call
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).on('ready',function(){
var username ="test@liferay.com";
var password ="test";
function make_base_auth(user, password) {
var tok = user + ':' + password;
var hash = btoa(tok);
return "Basic " + hash;
}
$.ajax({
url: 'http://localhost:8080/api/jsonws/country/get-countries',
dataType: "json",
data:{},
type: "get",
success: function(data){
alert(data[0].name);
},
beforeSend: function(xhr){
xhr.setRequestHeader('Authorization',make_base_auth(username, password));
},
complete: function(){
},
error: function(){
}
});

});
</script>
thumbnail
Abhed Dekavadiya, modificado hace 10 años.

RE: acces json web services liferay 6.2

Junior Member Mensajes: 74 Fecha de incorporación: 5/10/10 Mensajes recientes
Manuel Mancipe:
Greetings to all

I implemented the solution http://test@liferay.com:test@localhost:8080/api/jsonws and work

Thank you,



Hello Manuel,
I am trying this, but it's not working. Did you do any other configuration also ?
regards,
Abhed
thumbnail
Moisés Belda, modificado hace 9 años.

RE: acces json web services liferay 6.2

Junior Member Mensajes: 75 Fecha de incorporación: 20/04/13 Mensajes recientes
Abhed Dekavadiya:
Manuel Mancipe:
Greetings to all

I implemented the solution http://test@liferay.com:test@localhost:8080/api/jsonws and work

Thank you,



Hello Manuel,
I am trying this, but it's not working. Did you do any other configuration also ?
regards,
Abhed


If you want to test all json webservices (guest-allowed or not) with "http://localhost:8080/api/jsonws" API page list, you have to be logued in liferay portal. Try to open new browser tab with the same browser, put your user/pass, and then refresh API page list. Non-Guest methods will work without "Authenticated access required"
thumbnail
Juliana Myaki, modificado hace 10 años.

RE: acces json web services liferay 6.2

New Member Mensajes: 2 Fecha de incorporación: 8/10/13 Mensajes recientes
Use the following annotation on the method declaration (on your ServiceImpl.java class).

@AccessControlled(guestAccessEnabled=true)
public String myServiceMethod(String myParam){
    // my method code here
}


You can also put the same annotation on you ServiceImpl class declaration, but it's not recommended.
thumbnail
Ankur Srivastava, modificado hace 8 años.

RE: acces json web services liferay 6.2

Junior Member Mensajes: 58 Fecha de incorporación: 9/11/08 Mensajes recientes
Juliana Myaki Bueno:
Use the following annotation on the method declaration (on your ServiceImpl.java class).

@AccessControlled(guestAccessEnabled=true)
public String myServiceMethod(String myParam){
    // my method code here
}


You can also put the same annotation on you ServiceImpl class declaration, but it's not recommended.


Thanks for this information. Is there any documentation which provides more information on this ?
thumbnail
Jeffrey Paul Handa, modificado hace 8 años.

RE: acces json web services liferay 6.2

Liferay Master Mensajes: 541 Fecha de incorporación: 1/12/08 Mensajes recientes
Hi Ankur,

In addition to the JSON Web Services section of the official documentation, I'd recommend the recording of the Securing Remote Web Services dev.life session that Tomáš presented.