unscene / node-oauth

OAuth 1.0A Client Utilities

Home Page:http://github.com/unscene/node-oauth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is the README out of date maybe?

elspoono opened this issue · comments

The createClient function utilized in the README and samples is missing for several revisions back as far as I can see. I'm guessing there's some other way to use this library, but my ham fisted attempts to use the request method directly resulted in several more errors about "merge" being undefined and "fillURL" being undefined. I see both of those are set up as export methods. I can't figure out how this thing is supposed to work?

var sys = require('sys');
var oauth = require('oauth-client');
var factual_key = "FADSFS";
var factual_secret = "FDASFSA";
var client = oauth.createClient(80,'api.v3.factual.com',true);

Results in createClient undefined errors. If you give me a hint on how to use it, I might be able to figure it out and would definitely volunteer to update the documentation.

commented

There was a pull request that I merged in hastily. I should have update this sooner sorry about that. If you want you might be able to use anything earlier than 0.1.7.

I am going to work on updating this now.

commented

The documentation is based around an older version of node's http module.

Currently you use it like so:

var options = {
  host: 'www.google.com',
  port: 80,
  path: '/upload',
  method: 'POST'
};



var req = http.request(options, function(res) {
  console.log('STATUS: ' + res.statusCode);
  console.log('HEADERS: ' + JSON.stringify(res.headers));
  res.setEncoding('utf8');
  res.on('data', function (chunk) {
    console.log('BODY: ' + chunk);
  });
});

req.on('error', function(e) {
  console.log('problem with request: ' + e.message);
});

// write data to request body
req.write('data\n');
req.write('data\n');
req.end();

Based on that and looking at the .request() method. You just need to follow the standard http request api now but also pass in oauth_signature in the options, and provide it an HMAC.

Oh awesome, thanks. I ended up using ciaranj 's current version, which also uses the current standard http request api as I'm understanding it now, which exposed a simple .get method that works for the limited little 2 leg oauth simple get web service I was trying to use.

Http request docs for those interested:
http://nodejs.org/docs/v0.4.7/api/http.html#http.get

My code snippet using ciarianj's oauth in case it's useful to anyone stumbling into here with similar needs:

var OAuth = require(__dirname + '/oauth.js').OAuth;
var factual_key    = "YOUR_FACTUAL_KEY";
var factual_secret = "YOUR_FACTUAL_SECRET";
var factual = new OAuth(null, null, factual_key, factual_secret,'1.0', null,'HMAC-SHA1');
app.post('/factual',function(req,res){
  factual.get(
    'http://api.v3.factual.com/t/places.json?q='+escape(req.body.name)+','+escape(req.body.address)+'&limit=1',
    null,
    null,
    function (err, data, result) {
      var results = JSON.parse(data);
      if(results.status == 'ok'){
        res.send(results.response.data);
      }else{
        res.send({err: 'Error'})
      }
    });
});

are the readme and examples going to be updated? This issue was opened 4 months ago and still hasn't been addressed

commented

Yes, I have not had the time to do it. If you want to send a pull request
I will gladly update it, otherwise I will have to take care of it when I
can.

On Wed, Feb 1, 2012 at 1:36 PM, Brian Smith <
reply@reply.github.com

wrote:

are the readme and examples going to be updated? This issue was opened 4
months ago and still hasn't been addressed


Reply to this email directly or view it on GitHub:
#3 (comment)

Thanks,
Ryan Fairchild

commented

I have opened up a bugfix branch to address the issue of the library being out of date. You can track progress there.