angularjs - ionic 2 CSRF failed -
i taked csrf failed error;
failed load resource: server responded status of 403 (forbidden)
response _body: "{"detail":"csrf failed: referer checking failed - no referer."}" headers: headers ok: false status: 403 statustext: "forbidden" type: 2 url: "https://deneme.com/api/v1.0/channels/"
my codes;
uyegiris() { var veri,kullaniciveri; this.deneme=2; var headers = new headers(); headers.append('accept', 'application/json'); headers.append('content-type', 'application/x-www-form-urlencoded' ); //headers.append('authorization' , 'basic '+ btoa(tok)); let options = new requestoptions({ headers: headers }); let postparams = { username: this.user['usernameil'], password:this.user['password'], } this.http.post("https://deneme.com/api/v1.0/users/login/", postparams, options).timeout(2000) .subscribe(data => { veri = data['_body']; veri= veri.slice(1, -1); veri = veri.replace(/\\/g, ""); veri = json.parse(veri); console.log(veri); if(veri.msg_err) { let alert = this.alertctrl.create({ title: 'giriş hatası', subtitle: veri.msg_err, buttons: ['tamam'] }); alert.present(); } else { this.kanallistele(); } }, error => { console.log(error); this.deneme=error; }); } kanallistele() { var veri; this.kanallardiv=true; this.uyegirisdiv=false; this.kanallistelebtn = false; this.kanallistelebtn2 = false; var headers = new headers(); headers.append('accept', 'application/json'); headers.append('content-type', 'application/json' ); //headers.append('authorization' , 'basic '+ btoa(tok)); let options = new requestoptions({ headers: headers }); let postparams = { token: "381f13d7056-ce5fe474919", user_id: "71", } var veris="channel_name_"; this.http2.post("https://deneme.com/api/v1.0/channels/", postparams, options) .subscribe(data => { veri = data['_body']; console.log(veri); veri= veri.slice(1, -1); veri = veri.replace(/\\/g, ""); veri = json.parse(veri); for(var = 0 ;;i++) { if(!veri.channel_list['channel_name_' + (i)]) break; this.veriler.push({channelname: veri.channel_list['channel_name_' + (i)],channelid: veri.channel_list['channel_id_' + (i)]}); } }, error => { console.log(error); this.deneme=error;// error getting data }); }
this has nothing ionic. looks server / backend / whatsoever requires csrf tokens in order respond request , not attach them. should contact backend team in order add missing tokens request
Comments
Post a Comment