简体   繁体   中英

REST api authentication through json

I'm trying to do a simple REST api in a CakePhp app, using a REST plugin I found, which for Authorization uses http headers.

My question is, how can I supply through jQuery using json, a header like for example:

Authorization: TRUEREST username=wwwww&password=zzzzz&apikey=xxxxxyyyyyyy

$.ajax({
  // ...
  beforeSend: function(x) {
    x.setRequestHeader('Authorization', 'TRUEREST username=wwwww&password=zzzzz&apikey=xxxxxyyyyyyy');
  },
  // ...
});

Docs: http://api.jquery.com/jQuery.ajax/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM