Skip to content

Commit 0dd2d5e

Browse files
authored
ENH: Catch RefreshError in _try_credentials() (#227)
* Catch RefreshError in _try_credentials() * Add to changelog.
1 parent b204206 commit 0dd2d5e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

docs/source/changelog.rst

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Changelog
1919
This fixes a bug where pandas-gbq could not refresh credentials if the
2020
cached credentials were invalid, revoked, or expired, even when
2121
``reauth=True``.
22+
- Catch RefreshError when trying credentials. (:issue:`226`)
2223

2324
Internal changes
2425
~~~~~~~~~~~~~~~~

pandas_gbq/auth.py

+7
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ def save_user_account_credentials(credentials, credentials_path):
297297
def _try_credentials(project_id, credentials):
298298
from google.cloud import bigquery
299299
import google.api_core.exceptions
300+
import google.auth.exceptions
300301

301302
if not credentials:
302303
return None
@@ -310,3 +311,9 @@ def _try_credentials(project_id, credentials):
310311
return credentials
311312
except google.api_core.exceptions.GoogleAPIError:
312313
return None
314+
except google.auth.exceptions.RefreshError:
315+
# Sometimes (such as on Travis) google-auth returns GCE credentials,
316+
# but fetching the token for those credentials doesn't actually work.
317+
# See:
318+
# https://github.com/googleapis/google-auth-library-python/issues/287
319+
return None

0 commit comments

Comments
 (0)