端点继续返回401

时间:2017-04-11 20:33:56

标签: vue.js vue-resource

以下工作正常。我获得了一个访问令牌,我可以在后续请求中使用它。

curl localhost:8080/oauth/token --user html5:password -d grant_type=password -d username=name -d password=pass

然而,当我尝试使用vue-resource进行同样的操作时,我得到了401。

const options = {
  headers: {
    Authorization: 'Basic ' + window.btoa('html5:password')
  },
  params: {
    'client_id': 'html5',
    'client_secret': 'password',
    'grant_type': 'password',
    'username': 'name',
    'password': 'pass'
  }
}

context.$http.post(LOGIN_URL, options).then((response) => {
  localStorage.setItem(this.storageKey, response.access_token)
  // TODO: Check 200 ok
  this.user.authenticated = true
  if (redirect) {
    Router.go(redirect)
  }
})

关于我做错了什么的任何线索?

1 个答案:

答案 0 :(得分:0)

这最终成为一个CORS问题,当客户端和服务器都使用相同的doamin服务时,它就会消失。

相关问题