我正在尝试获取Pocket的访问令牌。我正在使用MEAN堆栈。
我正在尝试在浏览器中运行以下查询:
https://getpocket.com/auth/authorize?
request_token=YOUR_REQUEST_TOKEN&redirect_uri=YOUR_REDIRECT_URI
但我不知道如何获得access_token
返回。
我尝试在POSTMAN应用程序中运行相同但它返回身份验证页面。 (PS:我能够使用POSTMAN获取foursquare的访问令牌。)
如何在此处获取access token
。
答案 0 :(得分:0)
我可以使用UI上的授权按钮来完成此操作。点击其中将发出http请求以通过响应返回令牌。
以下是angular的代码:
$scope.authPocket = function () {
var request = {
consumer_key: "your key",
redirect_uri: "http://localhost:8888/api/pocket/get_token"
};
Snippets.authPocket(request)
.success(function(code) {
console.dir(code);
var redirect_uri = "http://localhost:8888/api/pocket/save_token";
var redirectUrl = 'https://getpocket.com/auth/authorize' +
"?request_token=" + code +
"&redirect_uri=" + redirect_uri;
console.log('Redirecting page to:\n' + redirectUrl);
$window.location.href = redirectUrl;
});
};
因此,当用户授权(或拒绝)您的应用程序的请求令牌时,Pocket会打开您在调用/ v3 / oauth / request时提供的redirect_uri,将用户返回到您的应用程序。 / p>
希望有所帮助。