Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oauth library doesn't like it when you set request body to None #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kwellman
Copy link

@kwellman kwellman commented Jun 7, 2013

When I run the test_v2.py file I get the traceback pasted below. The oauth2 library doesn't handle a request body of None very well. The following pull request fixes this issue by setting the request body to an empty string rather than None.

Creating v2 Etsy API, base url=http://openapi.etsy.com/v2.
Not using cached method table.
Traceback (most recent call last):
  File "./test_v2.py", line 51, in <module>
    etsy_api = Etsy(config.api_key, etsy_oauth_client=oauth_client, etsy_env=etsy_env, log=my_log)
  File "/usr/local/lib/python2.7/dist-packages/etsy/_v2.py", line 21, in __init__
    super(EtsyV2, self).__init__(api_key, key_file, method_cache, log)
  File "/usr/local/lib/python2.7/dist-packages/etsy/_core.py", line 262, in __init__
    self._get_methods(method_cache)
  File "/usr/local/lib/python2.7/dist-packages/etsy/_core.py", line 272, in _get_methods
    ms = self.method_cache.get()
  File "/usr/local/lib/python2.7/dist-packages/etsy/_core.py", line 179, in get
    ms = self.api.get_method_table()
  File "/usr/local/lib/python2.7/dist-packages/etsy/_core.py", line 286, in get_method_table
    return self._get('GET', '/')
  File "/usr/local/lib/python2.7/dist-packages/etsy/_core.py", line 328, in _get
    data = self._get_url(url, http_method, content_type, body)
  File "/usr/local/lib/python2.7/dist-packages/etsy/_v2.py", line 25, in _get_url
    return self.etsy_oauth_client.do_oauth_request(url, http_method, content_type, body)
  File "/usr/local/lib/python2.7/dist-packages/etsy/oauth.py", line 43, in do_oauth_request
    resp, content = self.request(url, http_method, body=body)
  File "/usr/local/lib/python2.7/dist-packages/oauth2/__init__.py", line 662, in request
    req.sign_request(self.method, self.consumer, self.token)
  File "/usr/local/lib/python2.7/dist-packages/oauth2/__init__.py", line 493, in sign_request
    self['oauth_body_hash'] = base64.b64encode(sha(self.body).digest())
TypeError: must be string or buffer, not None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant