Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add partial support for falsy parameters #9

Closed
wants to merge 1 commit into from

Conversation

jmendiara
Copy link
Contributor

Cause falsy permissive comparisons, all falsy values are considered '' when computing the signature

var parameters = { 
 a: '',
 b: null,
 c: undefined,
 d: false,
 e: 0,
 f: [],
 g: true,
 h: 1
};
//...
var signature = oauthSignature.generate(httpMethod, url, parameters, consumerSecret, tokenSecret);

//URL used for signature
//a=&b=&c=&d=&e=&f=&g=true&h=1

This PR solves the false and 0 use case, following the same approach used for true and Number, creating an URL

//a=&b=&c=&d=false&e=0&f=&g=true&h=1

@jmendiara
Copy link
Contributor Author

Sorry, I have no time for making test

@jmendiara jmendiara mentioned this pull request Sep 25, 2014
@bettiolo
Copy link
Owner

Hi @jmendiara,
The comment I wrote for the issue #10 answers this as well:
#10 (comment)

Please, tell me if this clarifies the situation.

@jmendiara
Copy link
Contributor Author

This is a matter of parameter serialization, not RFC stuff. If I want to send
GET http://foo.com/bar?from=0&to=1&oauthStuff

I would need to encode the parameters this way

var params = {
   from: '0',
   to: 1
};
oauthSignature.generate(..., params, ....);

otherwise, the server signature will fail cause of you signed the url
GET http://foo.com/bar?from=&to=1&oauthStuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants