之前做了一套angular与springboot + secrity +auth2.0的验证授权,在angular中
$http({
method: 'POST',
url: 'localhost:8080/oauth/token',
data: $.param({
username: xxxxxxxxx,
password: xxxxxxxxxxx,
grant_type: 'password'
}),
headers :{
"Content-Type" : 'application/x-www-form-urlencoded',
"Authorization" : 'Basic XXXXXXXXXXXXXXX'
}
}).then(function successCallback(response) {
// 请求成功执行代码
localStorageService.set('id_token', response.data.access_token);
}, function errorCallback(response) {
// 请求失败执行代码
notify.closeAll();
notify({message: '登陆失败!请输入正确的用户名和密码'});
});
直接就可以得到token,并放到localstorage中,但在vue中
let headers = {