Skip to content

Commit

Permalink
Merge branch 'master' of github.com:idangazit/oauthlib
Browse files Browse the repository at this point in the history
  • Loading branch information
pydanny committed Mar 14, 2012
2 parents c86f971 + 5cba7e1 commit 6cc32aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
12 changes: 4 additions & 8 deletions oauthlib/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ def __init__(self, client_key, client_secret,
if self.signature_method == SIGNATURE_RSA and self.rsa_key is None:
raise ValueError('rsa_key is required when using RSA signature method.')

def get_oauth_signature(self, uri, http_method=u'GET', body=None,
def get_oauth_signature(self, uri, http_method=u'GET', body='',
headers=None):
"""Get an OAuth signature to be used in signing a request"""
body = body or ''
headers = headers or {}

if self.signature_method == SIGNATURE_PLAINTEXT:
Expand Down Expand Up @@ -88,14 +87,13 @@ def get_oauth_params(self):

return params

def _contribute_parameters(self, uri, params, body=None, headers=None):
def _contribute_parameters(self, uri, params, body='', headers=None):
if self.signature_type not in (SIGNATURE_TYPE_BODY,
SIGNATURE_TYPE_QUERY,
SIGNATURE_TYPE_AUTH_HEADER):
raise ValueError('Unknown signature type used.')

# defaults
body = body or ''
headers = headers or {}
complete_uri = uri

Expand All @@ -112,11 +110,10 @@ def _contribute_parameters(self, uri, params, body=None, headers=None):

return complete_uri, body, headers

def sign_request(self, uri, http_method=u'GET', body=None, headers=None):
def sign_request(self, uri, http_method=u'GET', body='', headers=None):
"""Get the signed uri and authorization header.
Authorization header will be None if signature type is "query".
"""
body = body or ''
headers = headers or {}

# get the OAuth params and contribute them to either the uri or
Expand Down Expand Up @@ -152,7 +149,7 @@ def get_resource_owner_secret(self, resource_owner_key):
def check_timestamp_and_nonce(self, timestamp, nonce):
raise NotImplementedError("Subclasses must implement this function.")

def check_request_signature(self, uri, http_method=u'GET', body=None,
def check_request_signature(self, uri, http_method=u'GET', body='',
headers=None):
"""Check a request's supplied signature to make sure the request is
valid.
Expand All @@ -161,7 +158,6 @@ def check_request_signature(self, uri, http_method=u'GET', body=None,
.. _`section 3.2`: http://tools.ietf.org/html/rfc5849#section-3.2
"""
body = body or ''
headers = headers or {}

# extract parameters
Expand Down
3 changes: 2 additions & 1 deletion oauthlib/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def normalize_base_string_uri(uri):
return urlparse.urlunparse((scheme, netloc, path, '', '', ''))


def collect_parameters(uri_query=None, body=None, headers=None,
def collect_parameters(uri_query='', body='', headers=None,
exclude_oauth_signature=True):
"""Collect parameters from the uri query, authorization header, and request
body.
Expand All @@ -78,6 +78,7 @@ def collect_parameters(uri_query=None, body=None, headers=None,
.. _`section 3.4.1.3.1`: http://tools.ietf.org/html/rfc5849#section-3.4.1.3.1
"""
headers = headers or {}
params = []

if uri_query:
Expand Down

0 comments on commit 6cc32aa

Please sign in to comment.