API
Version 7.x > API > Hash authentication in REST request View modes: 
User avatar
Member
Member
n.oskian-indice - 5/14/2013 6:00:58 AM
   
Hash authentication in REST request
Hello,

I am having trouble with the hash authentication in the rest service request. I make an ajax call like this

var params = { 'format': 'json', 'where': 'LocationZipCode=' + code };
$j.ajax({
type: 'GET',
url: '/rest/customtableitem.customtable.Location/all',
dataType: 'json',
data: params,
username: 'xxxx',
password: 'xxxx',
error: function (xhr, ajaxOptions, thrownError) {
alert(thrownError);
},
success: function (response) {
//some code here
}
});

and it's working. Then I generate the hash in the site manager for the given url, remove the username & password from the ajax call and I add the hash parameter like this:
var params = { 'format': 'json', 'where': 'LocationZipCode=' + code, 'hash': 'I_write_the_hash_code_here' };
and it requires authentication. Should i do something different?

Thank you in advance,
Natalie Oskian

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 5/25/2013 11:43:27 PM
   
RE:Hash authentication in REST request
Hello Natalie,

As we discussed in the emails too, the problem is that the authentication hash is formed from the complete URL including the querystring parameters, therefore that dynamic generation won't work and it will require one of two standard authentication means (Basic/Forms).
You would need to generate the hash strings on the server for all query parameter combinations (which can be effectively done for small volumes, but not for Zip code..) and then select and use the appropriate one for authenticating the request.

Please feel free to contact us if you have any additional questions.

Regards,
Zdenek