diff --git a/oauth2/__init__.py b/oauth2/__init__.py index 835270e3..029b25fc 100644 --- a/oauth2/__init__.py +++ b/oauth2/__init__.py @@ -637,7 +637,7 @@ 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,auth_method=None): DEFAULT_POST_CONTENT_TYPE = 'application/x-www-form-urlencoded' if not isinstance(headers, dict): @@ -670,11 +670,19 @@ def request(self, uri, method="GET", body='', headers=None, realm = schema + ':' + hierpart + host - if is_form_encoded: + if auth_method is None: + if is_form_encoded: + auth_method="body" + elif method == "GET": + auth_method="query_string" + else: + auth_method="authorization" + + if auth_method == "body": body = req.to_postdata() - elif method == "GET": + elif auth_method == "query_string": uri = req.to_url() - else: + elif auth_method == "authorization": headers.update(req.to_header(realm=realm)) return httplib2.Http.request(self, uri, method=method, body=body,