jsOAuth NodeJS module

119 views
Skip to first unread message

Tian Permana

unread,
Jan 11, 2013, 5:02:46 AM1/11/13
to jso...@googlegroups.com
Where can i download the nodejs module version of jsOAuth? I found the npm package (https://npmjs.org/package/js-oauth), but it's not the latest version. 

Rob Griffiths

unread,
Jan 11, 2013, 5:11:30 AM1/11/13
to jso...@googlegroups.com
I stopped building the Node module a while back. The latest source is always at https://github.com/bytespider/jsOAuth

You'll need to build in order to get the node module.

If that's too much effort I wrote a new module on NPM called OAuthRequest which is a simpler API and was the start of work towards 2.0. 

You may find it useful.

Rob

-- 
Rob Griffiths
Sent with Sparrow

Tian Permana

unread,
Jan 11, 2013, 5:17:19 AM1/11/13
to jso...@googlegroups.com
Why is it Rob? I try to use it as Twitter OAuth on my project, since twitter doesn't allow the OAuth in client side, and the other nodejs OAuth modules doesn't support the three legged request :(

Rob Griffiths

unread,
Jan 11, 2013, 5:21:58 AM1/11/13
to jso...@googlegroups.com
As far as I know, no one really used it.
There are much better modules on NPM such as https://npmjs.org/package/everyauth 

-- 
Rob Griffiths
Sent with Sparrow

Tian Permana

unread,
Jan 11, 2013, 7:54:08 AM1/11/13
to jso...@googlegroups.com
Hi Rob, i already build the node module. When i try to implement, and simply call the fetchRequestToken, it says "No valid request transport found."

Am i do it wrong? I am using expessjs.

Rob Griffiths

unread,
Jan 11, 2013, 8:01:16 AM1/11/13
to jso...@googlegroups.com
The node part requires the XHR module

npm install xhr



-- 
Rob Griffiths
Sent with Sparrow

Tian Permana

unread,
Jan 11, 2013, 8:51:48 AM1/11/13
to jso...@googlegroups.com
I don't know what's wrong, i have installed the xhr module inside the js-oauth directory, but it still says "No valid request transport found."

Rob Griffiths

unread,
Jan 11, 2013, 9:02:33 AM1/11/13
to jso...@googlegroups.com
I'm guessing you need to install xhr globally or in your projects node_modules folder

-- 
Rob Griffiths
Sent with Sparrow

Tian Permana

unread,
Jan 11, 2013, 9:09:50 AM1/11/13
to jso...@googlegroups.com
I've installed at my node_modules project folder, and the error message shown like this.
Any deprecated functions possible? 

TypeError: Object function createXHR(options, callback) {
    options = extend({}, createXHR.defaults, options)
    callback = once(callback)

    var xhr
        , uri = options.uri

    if ("cors" in options) {
        if (options.cors) {
            xhr = new XDR()
        } else {
            xhr = new XHR()
        }
    } else {
        if (protocolLess.test(uri) || hasProtocol.test(uri)) {
            xhr = new XDR()
        } else {
            xhr = new XHR()
        }
    }

    var load = options.status === false ? call(xhr, callback) :
            callWithStatus(xhr, callback)

    xhr.onreadystatechange = readystatechange
    xhr.onload = load
    xhr.onerror = error
    // IE9 must have onprogress be set to a unique function.
    xhr.onprogress = function () {
        // IE must die
    }
    xhr.ontimeout = noop
    xhr.open(options.method, uri)
    xhr.timeout = "timeout" in options ? options.timeout : 5000

    if (options.headers && xhr.setRequestHeader) {
        Object.keys(options.headers).forEach(function (key) {
            xhr.setRequestHeader(key, options.headers[key])
        })
    }

    xhr.send(options.data)

    return xhr

    function readystatechange() {
        this.readyState === 4 && load()
    }

    function error(evt) {
        callback.call(this, evt)
    }
} has no method 'open'

Rob Griffiths

unread,
Jan 11, 2013, 9:25:55 AM1/11/13
to jso...@googlegroups.com
It could be that XHR has moved on since. I can't help with that.

You could try OAuthRequest - its a little more direct, but it should work.

var OAuthRequest = require('OAuthRequest');
var xhr = new OAuthRequest();

xhr.open("GET", "http://www.google.co.uk", true);

xhr.addEventListener("readystatechange", function (event) {
    if (this.readyState === this.DONE && this.status >= 200) {
        doStuff(this.responseText);
    }
});

xhr.send(null);

The result of new OAuthRequest(); is a XHR like object.

You'll have to do the oath dance yourself or you could investigate Everyauth. It looks simp enough http://everyauth.com/#twitter-oauth

-- 
Rob Griffiths
Sent with Sparrow

Tian Permana

unread,
Jan 11, 2013, 9:47:33 AM1/11/13
to jso...@googlegroups.com
Bad luck :(

Is OAuthRequest works for OAuth1 also? Because you mentioned it designed for OAuth2?

Rob Griffiths

unread,
Jan 11, 2013, 9:48:57 AM1/11/13
to jso...@googlegroups.com
Sorry I meant it's jsOAuth v2, jsOAuth will always only work for OAuth 1.0

Sorry for the confusion.

-- 
Rob Griffiths
Sent with Sparrow

Reply all
Reply to author
Forward
0 new messages