REST api authentication through json

2019-05-19 09:52发布

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

标签: jquery json rest
1条回答
小情绪 Triste *
2楼-- · 2019-05-19 10:53
$.ajax({
  // ...
  beforeSend: function(x) {
    x.setRequestHeader('Authorization', 'TRUEREST username=wwwww&password=zzzzz&apikey=xxxxxyyyyyyy');
  },
  // ...
});

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

查看更多
登录 后发表回答