Skip to content

Instantly share code, notes, and snippets.

Created May 19, 2012 21:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
oauth_hook, imgur and requests error
import requests
import urlparse
from oauth_hook import OAuthHook
# consumer key + secret
# get access token, create client
client = requests.session(
hooks={'pre_request': OAuthHook(consumer_key=CONSUMER_KEY, consumer_secret=CONSUMER_SECRET)}
response ='')
qs = urlparse.parse_qs(response.text)
oauth_hook = OAuthHook(qs['oauth_token'], qs['oauth_token_secret'], CONSUMER_KEY, CONSUMER_SECRET)
client = requests.session(hooks={'pre_request': oauth_hook})
# request imgur stats
print 1
r = client.get("", data={"view":"all"})
print 2
# print r.text
Traceback (most recent call last):
File "/Users/ollieglass/.virtualenvs/carbonator/lib/python2.7/site-packages/requests/", line 47, in dispatch_hook
hook_data = hook(hook_data) or hook_data
File "/Users/ollieglass/.virtualenvs/carbonator/lib/python2.7/site-packages/oauth_hook/", line 187, in __call__
request.oauth_params['oauth_signature'] = self.signature.sign(request, self.consumer, self.token)
File "/Users/ollieglass/.virtualenvs/carbonator/lib/python2.7/site-packages/oauth_hook/", line 65, in sign
key, raw = self.signing_base(request, consumer, token)
File "/Users/ollieglass/.virtualenvs/carbonator/lib/python2.7/site-packages/oauth_hook/", line 26, in signing_base
key += escape(token.secret)
File "/Users/ollieglass/.virtualenvs/carbonator/lib/python2.7/site-packages/oauth_hook/", line 14, in <lambda>
escape = lambda url: urllib.quote(to_utf8(url), safe='~')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1248, in quote
if not s.rstrip(safe):
AttributeError: 'list' object has no attribute 'rstrip'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment