question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: Only unicode objects are escapable.

See original GitHub issue

Using requests 0.14.2 (tried 1.0.4 too and think I got the same thing) and Python 2.7.3. Getting this error when trying to make a request. Relevant part of stack trace:

  File "/Users/john/.virtualenvs/dashboard/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 215, in sign
    request.oauth_params.append(('oauth_signature', self.get_oauth_signature(request)))
  File "/Users/john/.virtualenvs/dashboard/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 67, in get_oauth_signature
    uri, headers, body = self._render(request)
  File "/Users/john/.virtualenvs/dashboard/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 137, in _render
    headers = parameters.prepare_headers(request.oauth_params, request.headers, realm=realm)
  File "/Users/john/.virtualenvs/dashboard/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/utils.py", line 32, in wrapper
    return target(params, *args, **kwargs)
  File "/Users/john/.virtualenvs/dashboard/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/parameters.py", line 58, in prepare_headers
    escaped_value = utils.escape(value)
  File "/Users/john/.virtualenvs/dashboard/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/utils.py", line 56, in escape
    raise ValueError('Only unicode objects are escapable.')
ValueError: Only unicode objects are escapable.

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
theladyjayecommented, Jan 5, 2013

Add this line to the top of your python module:

from __future__ import unicode_literals
0reactions
marco-lancinicommented, Mar 9, 2013

I encountered the same problem. The fact is that in this way:

credentials = parse_qs(r.content)
resource_owner_key = credentials.get('oauth_token')
resource_owner_secret = credentials.get('oauth_token_secret')

both resource_owner_key and resource_owner_secret are lists containing one element each. I solved this issues simply extracting the only element present in each list

resource_owner_key = credentials.get('oauth_token')[0]
resource_owner_secret = credentials.get('oauth_token_secret')[0]
Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Failed to send request: Only unicode objects are ...
It looks like you are using tweepy to get sentiment from tweets. You need Twitter API credentials to do so. What this error...
Read more >
Only unicode objects are escapable. · Issue #523
TweepError: Failed to send request: Only unicode objects are escapable. Got <generator object at 0xb7050cd4> of type <type 'generator'>.
Read more >
python oauthlib: in escape ValueError "Only unicode objects ...
Django : python oauthlib: in escape ValueError " Only unicode objects are escapable " [ Beautify Your Computer ...
Read more >
python oauthlib: in escape ValueError "Only unicode ...
I got this error when I did not provide my OAuth Consumer key and secrets in my django settings file. It's essentially a...
Read more >
Frequently asked questions — OAuthLib 3.2.1 documentation
What does ValueError Only unicode objects are escapable. Got one of type X. mean?¶. OAuthLib uses unicode everywhere and when creating a OAuth...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found