bytespider / jsOAuth

JavaScript implimentation of the OAuth protocol. Currently supports version 1.0 (RFC5849) of the specification. Node.js & CommonJS compatible.
http://bytespider.github.com/jsOAuth/
MIT License
556 stars 108 forks source link

Signed requests via jQuery.ajax for both Spine and Backbone #23

Closed bytespider closed 12 years ago

bytespider commented 12 years ago

Move all signing code to an XHR compatible API with which jQuery.ajax can use.

myOAuth = new OAuth({
    /* ... */
});
$.ajaxSettings.xhr = function () {
    return myOAuth.signedConnection;
};
funkatron commented 12 years ago

That's interesting. I think as long as one can go in and pull out the signed headers, that allows the greatest compatibility (which this may do). If helper methods were available for popular frameworks (jQ… and others, I guess) – that made it super easy to integrate, even better.

bytespider commented 12 years ago

I'm planning on writing the object with the same API, so would proxy getResponseHeader on the OAuthRequest to the real XMLHttpRequest. jsOAuth will retain its familiar API methods, but internally will be signed using the OAuthRequest object instead which can be then pulled out and pushed into jQuery once the main authentication has been completed. Or alternatively be used separately away from the jsOAuth library.

funkatron commented 12 years ago

Seems like a reasonable approach. Tally ho!

bytespider commented 12 years ago

I may not have answered your question directly, but I plan on OAuthRequest being a direct replacement for XHR so you may not need to pull out the signed headers in practice.

Assuming that transport factories would build the correct XHR to proxy off.