【发布时间】:2017-10-25 07:07:43
【问题描述】:
我正在尝试通过我的 React Native 项目中的 oauth/tokens 登录。我已经用 POSTMAN 进行了测试,当我从 axios 发送数据时,它运行良好。但是当我尝试从我的应用程序发送时,它给了我 错误:请求失败,状态码为 400 我的代码是:
axios({
method: 'post',
url: 'http://183.172.100.84:8000/oauth/token',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
},
data: {
client_id : '2',
client_secret : 'secret',
grant_type : 'password',
email : this.state.userEmail,
password : this.state.userPassword
}
})
.then((response) => {
console.log(response.data);
})
【问题讨论】:
-
将您的
Content-Type更改为application\json并重试
标签: laravel-5 react-native oauth axios laravel-passport