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

Already on GitHub? Sign in to your account

Client.request mangles query strings #25

Closed
simonw opened this Issue Aug 18, 2010 · 1 comment

Comments

Projects
None yet
1 participant

simonw commented Aug 18, 2010

If I try to make an OAuth signed request to the following URL:

http://api.twitter.com/1/users/show.json?screen_name=simonw

I get this error:

{u'request': u'/1/users/show.json?oauth_version=1.0&oauth_token=...&screen_name=%5B%27simonw%27%5D&oauth_nonce=...&oauth_timestamp=...&oauth_signature=...&oauth_consumer_key=...&oauth_signature_method=HMAC-SHA1', u'error': u'Not found'}

The screen_name value has been passed through as:

%5B%27simonw%27%5D

Which URL decodes to the following string:

"['simonw']"

What's happened here is that somewhere inside the oauth2 library my original ?screen_name=simonw querystring has been decoded in to a list, using cgi.parse_qs - and that list has then been converted in to a string using Python's default string representation.

I think the code at fault is on line 578 in the Client.request method:

elif method == "GET":
    parsed = urlparse.urlparse(uri)
    parameters = parse_qs(parsed.query)

That third line should be:

    parameters = dict(parse_qsl(parsed.query))

simonw commented Aug 18, 2010

Ignore this - it looks like I'm using version 1.0. Later versions have fixed the problem.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment