javascript - How, can i access tastypie authenticate webservice through ajax -


I am trying to use AJAX under the webservice, but it is not working. Username: - Root password: - Rohit

Ajax function

  $ .ajax ({type: "POST", url: "http: //task.woo. Gy / api / v1 / article /? Format = json ", data:" {'username': 'root', 'password': 'rohit'} ", content type:" app / jason; charset = utf-8 ", Success: AjaxCallSucceed_allorder, Datatype:" Jason ", Failure: AjaxCollfelde_Alander}); Function ajaxCallSucceed_allorder () {warning ('success'); } Function ajaxCallFailed_allorder () {warning ('unsuccessful'); }  "post-text" itemprop = "text"> 

Let's start sending your username and password in clear text on the Internet. Tastypie is an API key authentication mechanism that allows you to log in with the user and the API key (no password). There is a way for a new user to automatically create an API key, and I believe there is a management command to make a key for existing users.

For Ajax calls, either get the parameter in the user name and the key URL or use an authority header. You can use it for the following options:

 Before : Function (Excerpt) {xhr.setRequestHeader ("Authorization", "Authority: Apocrypha & lt; Username:; & Lt; api_key & gt; "); },  

mixture of: and


Comments