Pomax / node-flickrapi

A node.js (and client-library) implementation of the Flickr API with oauth API key authentication and API method proxying
177 stars 52 forks source link

authenticate never calls callback #68

Closed rschlack closed 9 years ago

rschlack commented 9 years ago
Flickr.authenticate(flickrOptions, function(error, response) {
               console.log('response from flickr api call');
               console.log(response);
});

If I use the option callback = "oob" I get a browser authentication and success page from flickr, but the console never logs the messages above.

When I try to set a callback url I am returned an oauth_token and oauth_verifier, but I can't figure out how to exchange these for a flickr_access_token. Also the console never logs the response form the authenticate.

If I call tokenonly I do get a callback and can get images after that. It's just the authenticate that I can't get to work.

Pomax commented 9 years ago

Can you explain a little more on what you're doing, since both those solutions work on every machine I test on - when you use the test.js file to test authentication (use node test testAuthenticated), does that run the normal process? If so, there might be something odd going on in your own code.

rschlack commented 9 years ago

I'm using meteorhacks:npm package in meteor to call this api. Here you can see where I load the api in use npmRequire. The other api seems to work to get images. When I click a button and execute the flickrAuthorize code I get the proper popup from flickr and authorize my app. I then get the next page which shows the authorization code. But the response never returns into the callback.

I then tried to uncomment that callback line. The callback does work, but the response I get back has the oauth_token and oauth_verifier, but I can't get it to exchange the token for the access token. I even tried just doing a rest call for this last step, but I don't have the token secret to use for the signature generation.

var flickrOptions = {
          api_key: "xxxxxxxxxxxxxx",
          secret: "xxxxxxxxxxxxxx",
         // callback: "http://localhost:3000/flickrCallback"
 };
  Meteor.methods({
    'flickrAuthorize' : function () {
        var Flickr = Meteor.npmRequire('flickrapi');

            Flickr.authenticate(flickrOptions, function(error, response) {
                      console.log('response from flickr api call');
               console.log(response);
        });

    },
Pomax commented 9 years ago

I have no experience with Meteor, so let's first see if this is a problem with your code, or with my code: please use the test.js script that is in this repo, with the testAuthenticated runtime option, to see if that authenticates properly.

If it does, then this module is working exactly it should, and we consequently know that the problem here is Meteor, not the flickr api module, and you can file this issue against them to see if they know what's going wrong.

If it doesn't, then there is a problem with the flickr api module and we can see what needs to be fixed to make it work.

Pomax commented 9 years ago

hi @rschlack, can you check whether test.js works fine or not, so that we can determine whether this is node-flickrapi, or meteor? (if not, I'll probably close this issue in a few days due to insufficient information to debug the problem with)