I thought I'd refactor my Python class for accessing Project Place via its REST API using the purportedly more human
. A bit of reading and a bit of prodding and poking suggests that when it comes to OAuth, everything sucks, including Requests.
After a bit of faffing with the refactoring, I yanked the bare minimum of code into a single file. No subroutines or classes. Not a single indent:
Traceback (most recent call last):
File "/Users/bob/Dropbox/Coding/Python/ProjectPlace (requests)/requests_test.py", line 19, in
r = requests.get('https://api.projectplace.com/1/user/me/profile.json', auth=auth)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/api.py", line 65, in get
return request('get', url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/safe_mode.py", line 39, in wrapped
return function(method, url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/api.py", line 51, in request
return session.request(method=method, url=url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/sessions.py", line 241, in request
r.send(prefetch=prefetch)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/models.py", line 521, in send
r = self.auth(self)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/auth.py", line 102, in __call__
unicode(r.full_url), unicode(r.method), r.data, r.headers)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/oauthlib/oauth1/rfc5849/__init__.py", line 213, in sign
request.oauth_params.append((u'oauth_signature', self.get_oauth_signature(request)))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/oauthlib/oauth1/rfc5849/__init__.py", line 65, in get_oauth_signature
uri, headers, body = self._render(request)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/oauthlib/oauth1/rfc5849/__init__.py", line 135, in _render
headers = parameters.prepare_headers(request.oauth_params, request.headers)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/oauthlib/oauth1/rfc5849/utils.py", line 28, in wrapper
return target(params, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/oauthlib/oauth1/rfc5849/parameters.py", line 55, in prepare_headers
escaped_value = utils.escape(value)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/packages/oauthlib/oauth1/rfc5849/utils.py", line 52, in escape
raise ValueError('Only unicode objects are escapable.')
ValueError: Only unicode objects are escapable.