Add support for POST requests and additional data parameters #1

Open
wants to merge 1 commit into
from

Projects

None yet

1 participant

jhubert commented Sep 24, 2012

This can cause the URL to be extremely long, which may have issues in
some browsers. However, for simple posts requests it works like a charm.

@jhubert jhubert Add support for POST requests and additional data parameters
This can cause the URL to be extremely long, which may have issues in
some browsers. However, for simple posts requests it works like a charm.
4ba2f59
jhubert commented Sep 24, 2012

Hi Dav. I've figured it out and it's working now. I had to change the method to POST and include all of the data in the URL signing. Adding all of the data seems odd, but it works and I couldn't get anything else to work, so I went with it.

I don't actually run any of the build tools on this laptop so I didn't generate the build versions of the lib. Sorry :-/

Also, I tried writing this patch in a YUI compliant way but I may not have done a great job. Thanks in advance for your tolerance.

In my script, I've broken the parameters out of the signedURL into an Auth header after it's generated and before I make the actual request.

Like this:

function oAuthHeaders(data) {
    var pieces = [];

    Y.each(data, function (i) {
        var bits = i.split('=');
        if (bits.length > 0) {
            if (bits[0].indexOf('oauth') > -1) {
                pieces.push(bits[0] + '="' + bits[1] + '"');
            }
        }
    });

    return 'OAuth ' + pieces.join(',');
}

Y.io.header("Authorization", oAuthHeaders(signedURL.split('?')[1].split('&')));
jhubert commented Sep 24, 2012

Honestly, this should probably be added as an extension of IO, but I don't quite have the chops to do a good job of that yet. I'll keep learning.

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