diff --git a/AUTHORS b/AUTHORS index d71461d9..686d4447 100644 --- a/AUTHORS +++ b/AUTHORS @@ -7,3 +7,4 @@ Ib Lundgren Daniel Greenfeld Caleb Brown Donald Stufft +Michael Vogt \ No newline at end of file diff --git a/oauthlib/oauth1/rfc5849/__init__.py b/oauthlib/oauth1/rfc5849/__init__.py index accfe1c6..d370525e 100644 --- a/oauthlib/oauth1/rfc5849/__init__.py +++ b/oauthlib/oauth1/rfc5849/__init__.py @@ -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. @@ -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: @@ -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. @@ -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):