Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
angular-jwt令牌头post错误_Angular_Header_Ionic3_Jwt_Wordpress Rest Api - Fatal编程技术网

angular-jwt令牌头post错误

angular-jwt令牌头post错误,angular,header,ionic3,jwt,wordpress-rest-api,Angular,Header,Ionic3,Jwt,Wordpress Rest Api,在ionic v3中,我使用以下代码通过jwt插件与wordpress api用户进行通信 我使用下面的代码进行令牌验证,但它不起作用,在另一种情况下,当我在postman或在线请求工具中测试时,通过此标头进行验证会起作用,因此我认为它与服务器端无关: validateAuthToken(token){ return this.http.post(this.API_USER_VALID, {} , {headers: {'Content-Type': 'application/x-www

ionic v3中,我使用以下代码通过jwt插件与wordpress api用户进行通信

我使用下面的代码进行令牌验证,但它不起作用,在另一种情况下,当我在postman或在线请求工具中测试时,通过此标头进行验证会起作用,因此我认为它与服务器端无关:

validateAuthToken(token){
    return this.http.post(this.API_USER_VALID, {} , {headers: {'Content-Type': 'application/x-www-form-urlencoded','Authorization': 'Bearer ' + token}})
      .subscribe((validdata)=>{
        console.log(validdata);
      });
  }
错误

对于登录我使用下面的代码,它工作正常 (按“内容类型”:“应用程序/json”标题不工作但按“内容类型”:“应用程序/x-www-form-urlencoded”工作):


我卡住了:(,如果有指南,请告诉我

在后端设置CORS并指定标题

请查找CORS,这是问题的原因
doLogin(username,password){
    return this.http.post(this.API_LOGIN,"username=" + username +
      "&password=" + password,{headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
      .subscribe((ddaa)=>{
        console.log(ddaa);
      });
  }