Raise ValueError if credentials and developerKey are both specified (#358)
diff --git a/googleapiclient/discovery.py b/googleapiclient/discovery.py
index fe19022..c8956f4 100644
--- a/googleapiclient/discovery.py
+++ b/googleapiclient/discovery.py
@@ -334,6 +334,10 @@
if http is not None and credentials is not None:
raise ValueError('Arguments http and credentials are mutually exclusive.')
+ if developerKey is not None and credentials is not None:
+ raise ValueError(
+ 'Arguments developerKey and credentials are mutually exclusive.')
+
if isinstance(service, six.string_types):
service = json.loads(service)
diff --git a/tests/test_discovery.py b/tests/test_discovery.py
index 89b0dd7..8818f4a 100644
--- a/tests/test_discovery.py
+++ b/tests/test_discovery.py
@@ -375,6 +375,13 @@
build(
'plus', 'v1', http=http, credentials=mock.sentinel.credentials)
+ def test_credentials_and_developer_key_mutually_exclusive(self):
+ http = HttpMock(datafile('plus.json'), {'status': '200'})
+ with self.assertRaises(ValueError):
+ build(
+ 'plus', 'v1', credentials=mock.sentinel.credentials,
+ developerKey=mock.sentinel.credentials)
+
class DiscoveryFromDocument(unittest.TestCase):
MOCK_CREDENTIALS = mock.Mock(spec=google.auth.credentials.Credentials)