Add support for oauth2client >= 3.0.0, < 4.0.0. (#265)
diff --git a/googleapiclient/channel.py b/googleapiclient/channel.py
index 702186b..7d0feb9 100644
--- a/googleapiclient/channel.py
+++ b/googleapiclient/channel.py
@@ -64,6 +64,13 @@
from oauth2client import util
import six
+# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
+# in '_helpers'.
+try:
+ from oauth2client import util
+except ImportError:
+ from oauth2client import _helpers as util
+
# The unix time epoch starts at midnight 1970.
EPOCH = datetime.datetime.utcfromtimestamp(0)
diff --git a/googleapiclient/discovery.py b/googleapiclient/discovery.py
index ecb75fa..8609e3a 100644
--- a/googleapiclient/discovery.py
+++ b/googleapiclient/discovery.py
@@ -69,8 +69,15 @@
from googleapiclient.model import RawModel
from googleapiclient.schema import Schemas
from oauth2client.client import GoogleCredentials
-from oauth2client.util import _add_query_parameter
-from oauth2client.util import positional
+
+# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
+# in '_helpers'.
+try:
+ from oauth2client.util import _add_query_parameter
+ from oauth2client.util import positional
+except ImportError:
+ from oauth2client._helpers import _add_query_parameter
+ from oauth2client._helpers import positional
# The client library requires a version of httplib2 that supports RETRIES.
diff --git a/googleapiclient/errors.py b/googleapiclient/errors.py
index 3d44de7..1b79d2f 100644
--- a/googleapiclient/errors.py
+++ b/googleapiclient/errors.py
@@ -23,7 +23,12 @@
import json
-from oauth2client import util
+# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
+# in '_helpers'.
+try:
+ from oauth2client import util
+except ImportError:
+ from oauth2client import _helpers as util
class Error(Exception):
diff --git a/googleapiclient/http.py b/googleapiclient/http.py
index 1e168c1..14580f0 100644
--- a/googleapiclient/http.py
+++ b/googleapiclient/http.py
@@ -55,6 +55,13 @@
from email.mime.nonmultipart import MIMENonMultipart
from email.parser import FeedParser
+# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
+# in '_helpers'.
+try:
+ from oauth2client import util
+except ImportError:
+ from oauth2client import _helpers as util
+
from googleapiclient import mimeparse
from googleapiclient.errors import BatchError
from googleapiclient.errors import HttpError
@@ -63,7 +70,6 @@
from googleapiclient.errors import UnexpectedBodyError
from googleapiclient.errors import UnexpectedMethodError
from googleapiclient.model import JsonModel
-from oauth2client import util
LOGGER = logging.getLogger(__name__)
diff --git a/googleapiclient/schema.py b/googleapiclient/schema.py
index ecb3f8b..9feaf28 100644
--- a/googleapiclient/schema.py
+++ b/googleapiclient/schema.py
@@ -65,7 +65,12 @@
import copy
-from oauth2client import util
+# Oauth2client < 3 has the positional helper in 'util', >= 3 has it
+# in '_helpers'.
+try:
+ from oauth2client import util
+except ImportError:
+ from oauth2client import _helpers as util
class Schemas(object):
diff --git a/setup.py b/setup.py
index 7dd6a0a..b4edba6 100644
--- a/setup.py
+++ b/setup.py
@@ -64,7 +64,7 @@
install_requires = [
'httplib2>=0.8,<1',
- 'oauth2client',
+ 'oauth2client>=1.5.0,<4.0.0',
'six>=1.6.1,<2',
'uritemplate>=0.6,<1',
]
diff --git a/tox.ini b/tox.ini
index 44f21da..a87dad3 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,10 +1,11 @@
[tox]
-envlist = py{26,27,33,34}-oauth2client{1,2}
+envlist = py{26,27,33,34}-oauth2client{1,2,3}
[testenv]
deps =
oauth2client1: oauth2client<2
oauth2client2: oauth2client>=2,<=3
+ oauth2client3: oauth2client>=3,<=4
keyring
mox
pyopenssl