Skip to content

Commit 860a637

Browse files
author
Jon Wayne Parrott
authored
Raise ValueError if credentials and developerKey are both specified (#358)
1 parent 20af04d commit 860a637

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

googleapiclient/discovery.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ def build_from_document(
334334
if http is not None and credentials is not None:
335335
raise ValueError('Arguments http and credentials are mutually exclusive.')
336336

337+
if developerKey is not None and credentials is not None:
338+
raise ValueError(
339+
'Arguments developerKey and credentials are mutually exclusive.')
340+
337341
if isinstance(service, six.string_types):
338342
service = json.loads(service)
339343

tests/test_discovery.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,13 @@ def test_credentials_and_http_mutually_exclusive(self):
375375
build(
376376
'plus', 'v1', http=http, credentials=mock.sentinel.credentials)
377377

378+
def test_credentials_and_developer_key_mutually_exclusive(self):
379+
http = HttpMock(datafile('plus.json'), {'status': '200'})
380+
with self.assertRaises(ValueError):
381+
build(
382+
'plus', 'v1', credentials=mock.sentinel.credentials,
383+
developerKey=mock.sentinel.credentials)
384+
378385

379386
class DiscoveryFromDocument(unittest.TestCase):
380387
MOCK_CREDENTIALS = mock.Mock(spec=google.auth.credentials.Credentials)

0 commit comments

Comments
 (0)