簡體   English   中英

在angularjs或nodejs中獲取Pocket訪問令牌

[英]Get Pocket access token in angularjs or nodejs

我正在嘗試獲取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

我可以使用UI上的授權按鈕來完成此操作。 點擊其中將發出http請求以通過響應獲取令牌。

以下是角度代碼:

$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將用戶返回到您的應用程序。

希望有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM