ciaranj / node-oauth

OAuth wrapper for node.js
MIT License
2.44k stars 662 forks source link

Custom Header for Binary Request (Twitter Media Download) #352

Open rogers-dwiputra opened 4 years ago

rogers-dwiputra commented 4 years ago

Hi, I don't know is this feature already exist or not because I can't find clear documentation about this, I need to make request that respond binary file (twitter media/image) so I can download it, here is my sample code :

`async function getTwitterUserProfileWithOAuth1 (username = 'youritguy4') { var oauth = new OAuth.OAuth( 'https://api.twitter.com/oauth/request_token', 'https://api.twitter.com/oauth/access_token', consumer_key, consumer_secret, '1.0A', null, 'HMAC-SHA1' ) const get = promisify(oauth.get.bind(oauth))

var file = fs.createWriteStream('./img/'+moment().unix()+'.jpg');

//this get request should return binary based get( https://ton.twitter.com/1.1/ton/data/dm/1247396998774280197/1247396972383764481/9pT24oPh.jpg, access_token_key, access_token_secret ).then((img) => { console.log(img); })

return 'ok' }`