From 53a4f0ee672db4a4b2282c36b97a848ebfc13abf Mon Sep 17 00:00:00 2001 From: Jon Gaulding Date: Tue, 5 Feb 2013 15:20:24 -0800 Subject: [PATCH] Add keyword argument for explicitly setting the realm to use in a requests OAuth Authorization header. Useful in case an OAuth implementation incorrectly rejects the auto-constructed realm. --- oauth2/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/oauth2/__init__.py b/oauth2/__init__.py index 835270e3..d7e31a56 100644 --- a/oauth2/__init__.py +++ b/oauth2/__init__.py @@ -637,7 +637,8 @@ def set_signature_method(self, method): self.method = method def request(self, uri, method="GET", body='', headers=None, - redirections=httplib2.DEFAULT_MAX_REDIRECTS, connection_type=None): + redirections=httplib2.DEFAULT_MAX_REDIRECTS, connection_type=None, + realm=None): DEFAULT_POST_CONTENT_TYPE = 'application/x-www-form-urlencoded' if not isinstance(headers, dict): @@ -668,7 +669,7 @@ def request(self, uri, method="GET", body='', headers=None, hierpart = '' host, rest = urllib.splithost(rest) - realm = schema + ':' + hierpart + host + realm = realm if realm != None else schema + ':' + hierpart + host if is_form_encoded: body = req.to_postdata()