Error in requesting "request_token"


#1

Below is my code written in nodeJS. I’m getting trouble in generating signature and in response I get “401” status code.
I’m requesting “https://api.twitter.com/oauth/request_token” url for request_token using POST method.

var oauth_headers = ['oauth_nonce='+nonce,
'oauth_consumer_key=' + consumerKey,
'oauth_callback=' + encodedCallback,
'oauth_signature_method=HMAC-SHA1',
'oauth_timestamp='+timestamp,
'oauth_version=1.0'];

var reqString = method + '&'+ encodeData(urlString) + '&' + encodeData(params) + encodeData(oauth_headers.join('&'));

var key = encodeData(consumerSecret)+'&';

var signature = encodeData(crypto.createHmac('sha1', key).update(reqString).digest('base64'));

oauth_headers.push('oauth_signature=' + signature);
var options = url.parse(urlString);

options.headers = {
  Authorization: 'OAuth ' + oauth_headers.join(',')
};

//Post data 
var reqGet = https.request(options, function(res) {
    console.log("statusCode: ", res.statusCode);
    //console.log("Header Response: ",res.headers);
}).on('error', function(error) {
	console.log("Error: ", error);
});

Is there any problem with Signature generation?