Skip to content

Instantly share code, notes, and snippets.

@BenHall
Created November 17, 2011 14:25
Show Gist options
  • Save BenHall/1373253 to your computer and use it in GitHub Desktop.
Save BenHall/1373253 to your computer and use it in GitHub Desktop.
node-oauth not happy.
var OAuth= require('oauth').OAuth;
var events = require('events');
var http = require('http');
var eyes = require('eyes');
var _ = require('underscore');
tweet = function() {
var oAuth= new OAuth("http://twitter.com/oauth/request_token",
"http://twitter.com/oauth/access_token",
"vknnKEthhunReqNATrhjvg", "",
"1.0A", null, "HMAC-SHA1");
oAuth.post("http://api.twitter.com/1/statuses/update.json", "411642032-lQnQzVEumOCFXcENCRA1sTcrEjRLPaI0jxEXGW9F",
"", {"status":"TEST oAuth twitter from Node"}, function(error, data) {
if(error) console.log(require('sys').inspect(error))
else console.log(data)
});
};
tweet();
var OAuth= require('oauth').OAuth;
var events = require('events');
var http = require('http');
var eyes = require('eyes');
var _ = require('underscore');
Object.prototype.tweet = function() {
var oAuth= new OAuth("http://twitter.com/oauth/request_token",
"http://twitter.com/oauth/access_token",
"vknnKEthhunReqNATrhjvg", "",
"1.0A", null, "HMAC-SHA1");
oAuth.post("http://api.twitter.com/1/statuses/update.json", "411642032-lQnQzVEumOCFXcENCRA1sTcrEjRLPaI0jxEXGW9F",
"", {"status":"TEST oAuth twitter from Node"}, function(error, data) {
if(error) console.log(require('sys').inspect(error))
else console.log(data)
});
};
Object.tweet();
@BenHall
Copy link
Author

BenHall commented Nov 17, 2011

Error message:

{ statusCode: 401,
data: '{"error":"Could not authenticate with OAuth.","request":"/1/statuses/update.json"}' }

@webjay
Copy link

webjay commented Jul 10, 2012

When sending like that I think the content-type is set to "application/x-www-form-urlencoded" where "application/json" is expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment