Skip to content

Instantly share code, notes, and snippets.

@mlowicki
Created March 15, 2011 16:42
Show Gist options
  • Select an option

  • Save mlowicki/871001 to your computer and use it in GitHub Desktop.

Select an option

Save mlowicki/871001 to your computer and use it in GitHub Desktop.
c = pycurl.Curl()
url = 'https://api.twitter.com/oauth/access_token'
url += '?x_auth_username=USER&x_auth_password=PASS&x_auth_mode=client_auth'
#print url
c.setopt(c.URL, str(url))
c.setopt(c.POST, 1)
form = CurlForm([])
form.add_string("x_auth_mode", "client_auth")
form.add_string("x_auth_password", "karamba")
form.add_string("x_auth_username", "mlowicki")
c.setopt(pycurl.HTTPPOST, form)
headers = [
"Authorization: " + str(req.META.get("HTTP_AUTHORIZATION")),
"Expect: ",
"Content-type: application/x-www-form-urlencoded",
]
c.setopt(c.HTTPHEADER, headers)
buffer = StringIO.StringIO()
c.setopt(c.WRITEFUNCTION, buffer.write)
c.setopt(c.FOLLOWLOCATION, 1)
c.setopt(c.MAXREDIRS, 5)
c.setopt(c.VERBOSE, 1)
c.perform()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment