Skip to content

Commit 6fe392a

Browse files
committed
API error on google-api-python-client==1.2
1 parent 4cf26aa commit 6fe392a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

pandas/io/gbq.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def get_application_default_credentials(self):
188188
from the environment. Or, the retrieved credentials do not
189189
have access to the project (self.project_id) on BigQuery.
190190
"""
191+
import httplib2
191192
try:
192193
from googleapiclient.discovery import build
193194
except ImportError:
@@ -202,11 +203,13 @@ def get_application_default_credentials(self):
202203
except:
203204
return None
204205

205-
# Check if the application has rights to the BigQuery project
206-
bigquery_service = build('bigquery', 'v2', credentials=credentials)
207-
jobs = bigquery_service.jobs()
208-
job_data = {'configuration': {'query': {'query': 'SELECT 1'}}}
206+
http = httplib2.Http()
209207
try:
208+
http = credentials.authorize(http)
209+
bigquery_service = build('bigquery', 'v2', http=http)
210+
# Check if the application has rights to the BigQuery project
211+
jobs = bigquery_service.jobs()
212+
job_data = {'configuration': {'query': {'query': 'SELECT 1'}}}
210213
jobs.insert(projectId=self.project_id, body=job_data).execute()
211214
return credentials
212215
except:

pandas/io/tests/test_gbq.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,17 @@ def _check_if_can_get_correct_default_credentials():
156156
# from the environment the tests are running in.
157157
# See Issue #13577
158158
test_requirements()
159+
import httplib2
159160
try:
160161
from googleapiclient.discovery import build
161162
except ImportError:
162163
from apiclient.discovery import build
163164
try:
164165
from oauth2client.client import GoogleCredentials
165166
credentials = GoogleCredentials.get_application_default()
166-
bigquery_service = build('bigquery', 'v2', credentials=credentials)
167+
http = httplib2.Http()
168+
http = credentials.authorize(http)
169+
bigquery_service = build('bigquery', 'v2', http=http)
167170
jobs = bigquery_service.jobs()
168171
job_data = {'configuration': {'query': {'query': 'SELECT 1'}}}
169172
jobs.insert(projectId=PROJECT_ID, body=job_data).execute()

0 commit comments

Comments
 (0)