From 4ebeb00b5c6a775e8156f45f7e812e5634cf620b Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Fri, 12 Oct 2018 10:35:49 -0700 Subject: [PATCH 1/2] Catch RefreshError in _try_credentials() --- pandas_gbq/auth.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandas_gbq/auth.py b/pandas_gbq/auth.py index 86ad929a..9f32bac7 100644 --- a/pandas_gbq/auth.py +++ b/pandas_gbq/auth.py @@ -297,6 +297,7 @@ def save_user_account_credentials(credentials, credentials_path): def _try_credentials(project_id, credentials): from google.cloud import bigquery import google.api_core.exceptions + import google.auth.exceptions if not credentials: return None @@ -310,3 +311,9 @@ def _try_credentials(project_id, credentials): return credentials except google.api_core.exceptions.GoogleAPIError: return None + except google.auth.exceptions.RefreshError: + # Sometimes (such as on Travis) google-auth returns GCE credentials, + # but fetching the token for those credentials doesn't actually work. + # See: + # https://github.com/googleapis/google-auth-library-python/issues/287 + return None From ec03addfac3aeff393612ebaabbfca3961dd2c7f Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Fri, 12 Oct 2018 11:13:30 -0700 Subject: [PATCH 2/2] Add to changelog. --- docs/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 68dc8d60..83c891bc 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -19,6 +19,7 @@ Changelog This fixes a bug where pandas-gbq could not refresh credentials if the cached credentials were invalid, revoked, or expired, even when ``reauth=True``. +- Catch RefreshError when trying credentials. (:issue:`226`) Internal changes ~~~~~~~~~~~~~~~~