Skip to content

Commit 6948176

Browse files
authored
[BUG] Don't load credentials from disk if reauth is True (#212)
* [BUG] Don't load credentials from disk if reauth is True If the credentials on disk are invalid, then `get_user_credentials()` may fail before it can fetch fresh credentials. Noticed first and fixed in pydata-google-auth package in pydata/pydata-google-auth@7ce7f3f Note about pydata-google-auth: eventually I'd like to move pandas-gbq to use that package for auth, but since I'm not sure when I'll have that package ready, I'm patching pandas-gbq, too. * syntax error
1 parent d98c621 commit 6948176

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pandas_gbq/auth.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,13 @@ def get_user_account_credentials(
159159
if os.path.isfile("bigquery_credentials.dat"):
160160
os.rename("bigquery_credentials.dat", credentials_path)
161161

162-
credentials = load_user_account_credentials(
163-
try_credentials,
164-
project_id=project_id,
165-
credentials_path=credentials_path,
166-
)
162+
credentials = None
163+
if not reauth:
164+
credentials = load_user_account_credentials(
165+
try_credentials,
166+
project_id=project_id,
167+
credentials_path=credentials_path,
168+
)
167169

168170
client_config = {
169171
"installed": {
@@ -178,7 +180,7 @@ def get_user_account_credentials(
178180
}
179181
}
180182

181-
if credentials is None or reauth:
183+
if credentials is None:
182184
app_flow = InstalledAppFlow.from_client_config(
183185
client_config, scopes=SCOPES
184186
)

0 commit comments

Comments
 (0)