I have created an application with its "callback URL" field as blank. I want to programatically use access_token function of oauth endpoint (https://dev.twitter.com/docs/api/1/post/oauth/access_token) and fetch oauth_token and oauth_token_secret.
I am able to do this from my browser my going to my applications and then generating the access token by click of a button. However, I want to do this automatically via a python program. https://dev.twitter.com/docs/api/1/post/oauth/access_token states that "callback URL" is a mandatory flied. Keeping it blank is not working as results in "401 Unauthorized Failed to validate oauth signature and token" response.
I do not want to use any twitter API wrappers or oauth library.
I have tried the following code -
import httplib
import uuid
from time import time
host = 'api.twitter.com'
url = "/oauth/request_token"
req = httplib.HTTPSConnection(host)
req.putrequest("GET", url)
req.putheader("Host", host)
uid = uuid.uuid4()
req.putheader("oauth_consumer_key" , consumer_key)
req.putheader("OAuth oauth_nonce" , uid.hex)
req.putheader("oauth_signature_method" , "HMAC-SHA1")
req.putheader("oauth_timestamp" , str(time.time()))
req.putheader("oauth_version" , "1.0")
req.putheader("oauth_callback" , "")
req.putheader("oauth_signature" , consumer_secret)
req.endheaders()
resp = req.getresponse()
data = resp.read()
print resp.status, resp.reason
print data
This returns "401 Unauthorized. Failed to validate oauth signature and token"
How do I access the my oauth_token and oauth_token_secret for the application which I have created?