Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions google/auth/_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,17 @@ def _get_gcloud_sdk_credentials(quota_project_id=None):
_LOGGER.debug("Cloud SDK credentials not found on disk; not using them")
return None, None

credentials, project_id = load_credentials_from_file(
credentials_filename, quota_project_id=quota_project_id
)
credentials._cred_file_path = credentials_filename
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
credentials, project_id = load_credentials_from_file(
credentials_filename, quota_project_id=quota_project_id
)
credentials._cred_file_path = credentials_filename

if not project_id:
project_id = _cloud_sdk.get_project_id()
if not project_id:
project_id = _cloud_sdk.get_project_id()

return credentials, project_id
return credentials, project_id


def _get_explicit_environ_credentials(quota_project_id=None):
Expand All @@ -339,12 +341,15 @@ def _get_explicit_environ_credentials(quota_project_id=None):
return _get_gcloud_sdk_credentials(quota_project_id=quota_project_id)

if explicit_file is not None:
credentials, project_id = load_credentials_from_file(
os.environ[environment_vars.CREDENTIALS], quota_project_id=quota_project_id
)
credentials._cred_file_path = f"{explicit_file} file via the GOOGLE_APPLICATION_CREDENTIALS environment variable"
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
credentials, project_id = load_credentials_from_file(
os.environ[environment_vars.CREDENTIALS],
quota_project_id=quota_project_id,
)
credentials._cred_file_path = f"{explicit_file} file via the GOOGLE_APPLICATION_CREDENTIALS environment variable"

return credentials, project_id
return credentials, project_id

else:
return None, None
Expand Down
26 changes: 16 additions & 10 deletions google/auth/_default_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io
import json
import os
import warnings

from google.auth import _default
from google.auth import environment_vars
Expand Down Expand Up @@ -116,14 +117,16 @@ def _get_gcloud_sdk_credentials(quota_project_id=None):
if not os.path.isfile(credentials_filename):
return None, None

credentials, project_id = load_credentials_from_file(
credentials_filename, quota_project_id=quota_project_id
)
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
credentials, project_id = load_credentials_from_file(
credentials_filename, quota_project_id=quota_project_id
)

if not project_id:
project_id = _cloud_sdk.get_project_id()
if not project_id:
project_id = _cloud_sdk.get_project_id()

return credentials, project_id
return credentials, project_id


def _get_explicit_environ_credentials(quota_project_id=None):
Expand All @@ -141,11 +144,14 @@ def _get_explicit_environ_credentials(quota_project_id=None):
return _get_gcloud_sdk_credentials(quota_project_id=quota_project_id)

if explicit_file is not None:
credentials, project_id = load_credentials_from_file(
os.environ[environment_vars.CREDENTIALS], quota_project_id=quota_project_id
)
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
credentials, project_id = load_credentials_from_file(
os.environ[environment_vars.CREDENTIALS],
quota_project_id=quota_project_id,
)

return credentials, project_id
return credentials, project_id

else:
return None, None
Expand Down
Binary file modified system_tests/secrets.tar.enc
Binary file not shown.