Skip to content

Commit bbf7264

Browse files
authored
Removing get_credentials() from core. (#3667)
* Removing `get_credentials()` from `core`. In the process also: - Slight re-org on `nox.py` config (to pass posargs) for `core` and `datastore` - Getting rid of last usage of `_Monkey` in datastore This is part of `@jonparrott`'s effort to slim down / stabilize `core`. * Removing `google.cloud.credentials` module from docs.
1 parent 2c1d421 commit bbf7264

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

packages/google-cloud-bigtable/google/cloud/bigtable/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
import os
3333

34+
import google.auth
3435
import google.auth.credentials
3536
from google.gax.utils import metrics
3637
from google.longrunning import operations_grpc
@@ -40,7 +41,6 @@
4041
from google.cloud._http import DEFAULT_USER_AGENT
4142
from google.cloud.client import _ClientFactoryMixin
4243
from google.cloud.client import _ClientProjectMixin
43-
from google.cloud.credentials import get_credentials
4444
from google.cloud.environment_vars import BIGTABLE_EMULATOR
4545

4646
from google.cloud.bigtable import __version__
@@ -211,7 +211,7 @@ def __init__(self, project=None, credentials=None,
211211
read_only=False, admin=False, user_agent=DEFAULT_USER_AGENT):
212212
_ClientProjectMixin.__init__(self, project=project)
213213
if credentials is None:
214-
credentials = get_credentials()
214+
credentials, _ = google.auth.default()
215215

216216
if read_only and admin:
217217
raise ValueError('A read-only client cannot also perform'

packages/google-cloud-bigtable/tests/unit/test_client.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -360,20 +360,19 @@ def test_constructor_both_admin_and_read_only(self):
360360
read_only=True)
361361

362362
def test_constructor_implicit_credentials(self):
363-
from google.cloud._testing import _Monkey
364-
from google.cloud.bigtable import client as MUT
363+
from google.cloud.bigtable.client import DATA_SCOPE
365364

366365
creds = _make_credentials()
367-
expected_scopes = [MUT.DATA_SCOPE]
368-
369-
def mock_get_credentials():
370-
return creds
366+
expected_scopes = [DATA_SCOPE]
371367

372-
with _Monkey(MUT, get_credentials=mock_get_credentials):
368+
patch = mock.patch(
369+
'google.auth.default', return_value=(creds, None))
370+
with patch as default:
373371
self._constructor_test_helper(
374372
None, None,
375373
expected_creds=creds.with_scopes.return_value)
376374

375+
default.assert_called_once_with()
377376
creds.with_scopes.assert_called_once_with(expected_scopes)
378377

379378
def test_constructor_credentials_wo_create_scoped(self):

0 commit comments

Comments
 (0)