Thanks for sharing the code Jon.
I executed it on my machine and it works very well. I’ll try to translate it to ruby as best as I can.
I guess something is just not right with the code Postman generated for me. Here’s what code Postman generates using Node request library:
var request = require("request");
var options = { method: 'GET',
url: 'https://ton.twitter.com/1.1/ton/data/dm/920660133419642886/920660123240067074/7hNzfpxZ.png',
headers: { authorization: 'OAuth oauth_consumer_key=\\"redacted\\",oauth_token=\\"redaceted\\",oauth_signature_method=\\"HMAC-SHA1\\",oauth_timestamp=\\"1508417698\\",oauth_nonce=\\"redacted\\",oauth_version=\\"1.0\\",oauth_signature=\\"redacted%3D\\"' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
And here’s the output:
↪ node nodescript.js
(node:1586) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 pipe listeners added. Use emitter.setMaxListeners() to increase limit
/Users/admin/Downloads/nodescript.js:30
if (error) throw new Error(error);
^
Error: Error: Exceeded maxRedirects. Probably stuck in a redirect loop https://ton.twitter.com/1.1/ton/data/dm/920660133419642886/920660123240067074/7hNzfpxZ.png
Will investigate why generated code looks like this and why it doesn’t work.
UPD:
Changing “headers: { authorization: …” bit to “oauth: twitter_oauth” makes all the difference, I wonder why 
UPD 2:
Got it working. Ruby code:
require 'faraday'
require 'simple_oauth'
hdr = SimpleOAuth::Header.new('GET', 'https://ton.twitter.com/1.1/ton/data/dm/920660133419642886/920660123240067074/7hNzfpxZ.png', {}, { consumer_key: 'redacted',consumer_secret: 'redacted',token: 'redacted',token_secret: 'redacted' })
response = Faraday.get do |req|
req.url('https://ton.twitter.com/1.1/ton/data/dm/920660133419642886/920660123240067074/7hNzfpxZ.png')
req.headers['Authorization'] = hdr.to_s
end
puts response.body # raw image
Still don’t know why header generated by either Postman or Twitter Gem did not work but I guess it doesn’t matter now.
Many Thanks Jon, you code was very inspiring 