【发布时间】:2017-04-17 09:19:40
【问题描述】:
我正在尝试使用 vue 和 laravel 护照连接生成 laravel 用户 API,但我的标题中不断出现授权错误。这是我的代码
<script>
import Hello from './components/Hello'
export default {
name: 'app',
components: {
Hello
},
created () {
const postData = {
grant_type: 'password',
client_id: 2,
client_secret: 'sXdg5nOO4UU2muiHaQnTq4hDQjyj17Kd9AeKuNEx',
username: 'robertrutenge@gmail.com',
password: 'password',
scope: ''
}
this.$http.post('http://localhost:8000/oauth/token', postData)
.then(response => {
console.log(response)
const header = {
'Accept': 'application/json',
'Authorization': ~'Bearer ' + response.body.access_token
}
this.$http.get('http://localhost:8000/api/user', {headers: header})
.then(response => {
console.log(response)
})
})
}
}
</script>
我已经进行了一项研究,大多数答案都建议修改 apache 配置文件或 .htaccess 文件,但这似乎对我来说也不起作用。任何帮助将不胜感激:-)
【问题讨论】:
标签: apache .htaccess laravel laravel-5 http-headers