Skip to content

Instantly share code, notes, and snippets.

@mehdimehdi
Created April 6, 2012 23:01
Show Gist options
  • Select an option

  • Save mehdimehdi/2323767 to your computer and use it in GitHub Desktop.

Select an option

Save mehdimehdi/2323767 to your computer and use it in GitHub Desktop.
import urllib
import urllib2
import oauth
CONSUMER_KEY = '50B4YwaUeSQvyCaFeI3TRg'
CONSUMER_SECRET = 'XXXX'
RESOURCE_URL = 'https://punchtab.uservoice.com/api/v1/tickets.json'
# Setup 2 legged OAuth consumer based on our admin "credentials"
consumer = oauth.OAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET)
# Construct the request manually and sign it using HMAC-SHA1
# Note: The params dictionary needs to be passed in separately from the base URL
request = oauth.OAuthRequest.from_consumer_and_token(
consumer, http_method='GET', http_url=RESOURCE_URL, parameters={})
request.sign_request(oauth.OAuthSignatureMethod_HMAC_SHA1(), consumer, None)
# See patch @ http://code.google.com/p/oauth/issues/detail?id=31
headers = request.to_header()
req = urllib2.Request(RESOURCE_URL, {}, headers)
response = urllib2.urlopen(req)
print response.read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment