HTTPUnauthorized -- can't get request token


Hi, I have been struggling to implement “Sign in with Twitter” for my app for a couple of weeks now. I followed the “Authorizing a request” page and have this equal to the DST string.

OAuth oauth_callback=“”, oauth_consumer_key=“MY-KEY-FROM-APP”,oauth_nonce=“NDg0ODI0MDY2ODkzOTc3NzE0NzgzNDYzMDg3ODA2”,oauth_signature=“QaTVVEUNlP7BLrZIlWER79M3pj4=”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1391814142”, oauth_version=“1.0”

I also followed the Sign in with Twitter page and Creating a Signature. The following code is what I use to make a request:
uri = URI.parse(“”)
https =, uri.port)
https.use_ssl = true
req =
req[“Authorization”] = DST
#req[“Content-Type”] = "application/x-www-form-urlencoded"
res = https.request(req)
puts res

The result of the final line is:
But the number at the end changes each time I run the program. I am new to coding in Ruby and have tried using gems to no avail, plus I don’t want to worry about gem maintenance.