2
我正在浏览this guide并试图从google api获取accses令牌。我艾伦得到了一个认证代码。所以我使用angularjs发送httprequest到谷歌服务器。问题是我总是得到不好的请求答案。这是我的代码:无法使用angularjs从谷歌获取访问令牌
$http({
method: 'POST',
url: 'https://accounts.google.com/o/oauth2/token',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
params : {
code : '4/heMv6ozWwCxS5RyTzCgThAgxvRyk.oske-bNEGOUTOl05ti8ZT3YnwwH8iQI',
client_id : GoogleAppInfo.clientId,
redirect_uri : GoogleAppInfo.redirect_uri,
client_secret : GoogleAppInfo.client_secret,
grant_type : 'authorization_code'
},
data :'Demo' //just data to apply the heaser
}).
success(function(data, status, headers, config) {
alert('secsses');
}).
error(function(data, status, headers, config) {
alert('error');
});
我已经使用PostMan chorme addon来测试我的参数,可以和它的工作的邮递员。 那里的错误是因为这个请求的授权码已过期,但它正在工作!
有没有人对这个问题有好感? 非常感谢!
我使用服务器代码来获取我的令牌。我不认为你想把你的秘密放在客户端设备上。 –