File tree 2 files changed +11
-5
lines changed
2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,7 @@ def get_application_default_credentials(self):
188
188
from the environment. Or, the retrieved credentials do not
189
189
have access to the project (self.project_id) on BigQuery.
190
190
"""
191
+ import httplib2
191
192
try :
192
193
from googleapiclient .discovery import build
193
194
except ImportError :
@@ -202,11 +203,13 @@ def get_application_default_credentials(self):
202
203
except :
203
204
return None
204
205
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 ()
209
207
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' }}}
210
213
jobs .insert (projectId = self .project_id , body = job_data ).execute ()
211
214
return credentials
212
215
except :
Original file line number Diff line number Diff line change @@ -156,14 +156,17 @@ def _check_if_can_get_correct_default_credentials():
156
156
# from the environment the tests are running in.
157
157
# See Issue #13577
158
158
test_requirements ()
159
+ import httplib2
159
160
try :
160
161
from googleapiclient .discovery import build
161
162
except ImportError :
162
163
from apiclient .discovery import build
163
164
try :
164
165
from oauth2client .client import GoogleCredentials
165
166
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 )
167
170
jobs = bigquery_service .jobs ()
168
171
job_data = {'configuration' : {'query' : {'query' : 'SELECT 1' }}}
169
172
jobs .insert (projectId = PROJECT_ID , body = job_data ).execute ()
You can’t perform that action at this time.
0 commit comments