2***@qq.com
2***@qq.com
  • 发布:2019-01-03 16:11
  • 更新:2019-01-03 16:11
  • 阅读:2465

OAuth第三方登录,调用接口的时候报400错误

分类:HTML5+
let path = handler.$apiRoot.oauthsitePath + '/OAuth/Token';  
          let params = {  
            grant_type: 'password',  
            client_id: handler.$globalParams.client_id,  
            client_secret: handler.$globalParams.client_secret,  
            username: type,  
            password: open_id  
          }  
          handler.axios({  
            url: path,  
            method: 'post',  
            data: params,  
            transformRequest: [function (data) {  
              console.log("data");  
              console.log(JSON.stringify(data));  
              let ret = '';  
              for (let it in data) {  
                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';  
              };  
              console.log("ret")  
              console.log(ret);  
              return ret;  
            }],  
            headers: {  
              'Content-Type': 'application/x-www-form-urlencoded'  
            }  
          })  
          .then((res) => {  
            console.log("res");  
            console.log(res);  
            if (res.status === 200) {  
              console.log(200);  
              handler.loadingStatus = false;  
              /* this.vuethis.$vux.loading.hide() */  
              window.localStorage.setItem('accessToken', res.data.access_token);  
              handler.$router.push({  
                path: '/user/relatelogin'  
              })  
            }else {  
              console.log('others');  
            }  
          })  
          .catch((err) => {  
            console.log("报错信息:")  
            console.log(err);   
            handler.$router.push({  
              path: '/user/relatelogin'  
            })  
          });    
        }

报400错误

[LOG] : 报错信息:
[LOG] : Error: Request failed with status code 400

2019-01-03 16:11 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复