【问题标题】:Get Pocket access token in angularjs or nodejs在 angularjs 或 nodejs 中获取袖珍访问令牌
【发布时间】:2015-03-04 15:46:28
【问题描述】:

我正在尝试获取 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

【问题讨论】:

  • 我遇到了同样的问题。我无法从请求中找到 access_token。

标签: javascript angularjs node.js authorization pocket


【解决方案1】:

我可以通过使用 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 将用户返回到您的应用程序。

希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-27
    • 1970-01-01
    • 2010-10-29
    • 2019-08-05
    • 2018-03-02
    • 2014-07-09
    相关资源
    最近更新 更多