Skip to content

OAuth authHeader method not creating a valid signature for POST requests with url encoded form parameters #366

Description

@chrisbottin

The OAuth authHeader method https://github.com/ciaranj/node-oauth/blob/master/lib/oauth.js#L574 is not accepting a extra_params required to create a valid signature for POST requests with url encoded form parameters.

The solution is straightforward and it would just require to add the extra_params params in the method...

Before the fix

exports.OAuth.prototype.authHeader= function(url, oauth_token, oauth_token_secret, method) {
  if( method === undefined ) {
    var method= "GET";
  }

  var orderedParameters= this._prepareParameters(oauth_token, oauth_token_secret, method, url, {});
  return this._buildAuthorizationHeaders(orderedParameters);
};

After the fix

exports.OAuth.prototype.authHeader= function(url, oauth_token, oauth_token_secret, method, extra_params) {
  if( method === undefined ) {
    var method= "GET";
  }

  if( extra_params === undefined ) {
    var extra_params= {};
  }

  var orderedParameters= this._prepareParameters(oauth_token, oauth_token_secret, method, url, extra_params);
  return this._buildAuthorizationHeaders(orderedParameters);
};

I'm happy to create a pull request if it's likely to be approved and merged, please advise.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions