Authorization Header using OAuth1.0 with Twitter API v1.1

nodejs
oauth
javascript

#1

I am building a search engine as a start-up project in Web Development. The search engine takes a string and queries the Wiki and Twitter API. I have been working on it for days and, I believe, I have found a nice, clean way to implement it.

BoyCook’s TwitterJSClient

In his code (which is beautifully written) he has set up a Twitter function which takes in a config variable and sets up the authorization for us. Is there something it is missing? I have been through it and it all looks great. I am new to Javascript and might be missing something…

My code:

var error = function (err, response, body) {
    console.log('ERROR [%s]', err);
};
var success = function (data) {
    console.log('Data [%s]', data);
};
var config = {
    "consumerKey": "{Mine}",
    "consumerSecret": "{Mine}",
    "accessToken": "{Mine}",
    "accessTokenSecret": "{Mine}",
    "callBackUrl": ""
}

var Twitter = require('twitter-node-client').Twitter;

var twitter = new Twitter(config);

twitter.getSearch({'q':'Lebron James','count': 10}, error, success);

Can anyone help? Have you done this before and know an easier way? Has anyone been able to get it working using postMessage()?

And yes… the origin is using HTTPS protocol. See: JBEngine. My app permission (on Twitter) is set to read only.

[EDIT] Should probably also mention that I glob’d it all together with browserify and am running the script client-side.