Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:simplegeo/python-oauth2
Browse files Browse the repository at this point in the history
  • Loading branch information
joestump committed Feb 15, 2010
2 parents df158fc + 340584e commit c773302
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 62 deletions.
13 changes: 9 additions & 4 deletions oauth2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import hmac
import binascii
import httplib2
from types import ListType

try:
from urlparse import parse_qs, parse_qsl
Expand Down Expand Up @@ -309,7 +310,10 @@ def to_header(self, realm=''):

def to_postdata(self):
"""Serialize as post data for a POST request."""
return urllib.urlencode(self)
# tell urlencode to deal with sequence values and map them correctly
# to resulting querystring. for example self["k"] = ["v1", "v2"] will
# result in 'k=v1&k=v2' and not k=%5B%27v1%27%2C+%27v2%27%5D
return urllib.urlencode(self, True)

def to_url(self):
"""Serialize as a URL for a GET request."""
Expand All @@ -324,8 +328,9 @@ def get_parameter(self, parameter):

def get_normalized_parameters(self):
"""Return a string that contains the parameters that must be signed."""
items = [(k, v) for k, v in self.items() if k != 'oauth_signature']
encoded_str = urllib.urlencode(sorted(items))
# 1.0a/9.1.1 states that kvp must be sorted by key, then by value
items = [(k, v if type(v) != ListType else sorted(v)) for k,v in sorted(self.items()) if k != 'oauth_signature']
encoded_str = urllib.urlencode(items, True)
# Encode signature parameters per Oauth Core 1.0 protocol
# spec draft 7, section 3.6
# (http://tools.ietf.org/html/draft-hammer-oauth-07#section-3.6)
Expand Down Expand Up @@ -580,7 +585,7 @@ def request(self, uri, method="GET", body=None, headers=None,
parameters = dict(parse_qsl(body))
elif method == "GET":
parsed = urlparse.urlparse(uri)
parameters = parse_qs(parsed.query)
parameters = parse_qsl(parsed.query)
else:
parameters = None

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup, find_packages

setup(name="oauth2",
version="1.0.2",
version="1.0.7",
description="Library for OAuth version 1.0a.",
author="Joe Stump",
author_email="joe@simplegeo.com",
Expand Down
Loading

0 comments on commit c773302

Please sign in to comment.