Flickr API Oauth(node-flickrapi)缓存oauth_verifier

时间:2015-07-08 16:27:40

标签: javascript node.js oauth flickr

我通过Oauth获得了经过身份验证的Flickr API的乐趣,并且由于node-flickrapi NPM而得到了node.js。每次我运行我的代码时,控制台都会告诉我 -

add the following variables to your environment:
export FLICKR_USER_ID="8443423@N08"
export FLICKR_ACCESS_TOKEN="*****************"
export FLICKR_ACCESS_TOKEN_SECRET="***************"

我认为这是为了维持会话并避免不得不重新进入oauth_verifier

enter image description here

enter image description here

谁能告诉我怎么做?我想禁止网页重定向,每次调用服务时都必须重新输入此代码。我的代码看起来像这样,否则工作正常 -

var Flickr = require("flickrapi"),
    flickrOptions = {
      api_key: "######################",
      secret: "###########"
    };

Flickr.authenticate(flickrOptions, function(error, flickr) {

    flickr.photos.search({
        api_key: "######################",
        text: "Red, Pandas",
        format: "json",
        content_type : 1,
        per_page : 10
    }, 
    function jsonFlickrApi (err, results) {

        results.photos.photo.forEach(function(photo) {

        var furl = "https://farm" + photo.farm +
                       ".staticflickr.com/" +
                        photo.server + "/" +
                        photo.id + "_" +
                        photo.secret + "_h" + ".jpg";

             flickr.photos.getPerms({
                api_key : "######################",
                photo_id : photo.id
             }, 
             function(err, perms){
                 console.log(perms)
                });

        });

    })

});

1 个答案:

答案 0 :(得分:0)

好吧,我的坏......

答案在于NPM包dotenv