Skip to content

Commit

Permalink
address some of the review points from Ib
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 committed Oct 29, 2012
1 parent 619c8db commit 30ea423
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Ib Lundgren
Daniel Greenfeld
Caleb Brown
Donald Stufft
Michael Vogt
9 changes: 5 additions & 4 deletions oauthlib/oauth1/rfc5849/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def get_oauth_params(self):

return params

def _render(self, request, formencode=False):
def _render(self, request, formencode=False, realm=None):
"""Render a signed request according to signature type
Returns a 3-tuple containing the request URI, headers, and body.
Expand All @@ -131,7 +131,7 @@ def _render(self, request, formencode=False):
# like the spec requires. This would be a fundamental change though, and
# I'm not sure how I feel about it.
if self.signature_type == SIGNATURE_TYPE_AUTH_HEADER:
headers = parameters.prepare_headers(request.oauth_params, request.headers, self.realm)
headers = parameters.prepare_headers(request.oauth_params, request.headers, realm=realm)
elif self.signature_type == SIGNATURE_TYPE_BODY and request.decoded_body is not None:
body = parameters.prepare_form_encoded_body(request.oauth_params, request.decoded_body)
if formencode:
Expand All @@ -144,7 +144,7 @@ def _render(self, request, formencode=False):

return uri, headers, body

def sign(self, uri, http_method=u'GET', body=None, headers=None):
def sign(self, uri, http_method=u'GET', body=None, headers=None, realm=None):
"""Sign a request
Signs an HTTP request with the specified parts.
Expand Down Expand Up @@ -212,7 +212,8 @@ def sign(self, uri, http_method=u'GET', body=None, headers=None):
request.oauth_params.append((u'oauth_signature', self.get_oauth_signature(request)))

# render the signed request and return it
return self._render(request, formencode=True)
return self._render(request, formencode=True,
realm=(realm or self.realm))


class Server(object):
Expand Down

0 comments on commit 30ea423

Please sign in to comment.