Skip to content

Commit a2d8238

Browse files
author
Jon Wayne Parrott
authored
Remove usage of GoogleCredentials (GoogleCloudPlatform#810)
1 parent 0924ff0 commit a2d8238

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+164
-324
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
Flask==0.12
22
google-cloud-datastore==0.22.1
33
gunicorn==19.6.0
4-
oauth2client==4.0.0

appengine/flexible/endpoints/clients/service_to_service_non_default/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import json
2121
import time
2222

23-
from googleapiclient.discovery import build
23+
import googleapiclient.discovery
2424
import httplib2
2525
from oauth2client.contrib.appengine import AppAssertionCredentials
2626
import webapp2
@@ -36,7 +36,8 @@ def generate_jwt():
3636
credentials = AppAssertionCredentials(
3737
'https://www.googleapis.com/auth/iam')
3838
http_auth = credentials.authorize(httplib2.Http())
39-
service = build(serviceName='iam', version='v1', http=http_auth)
39+
service = googleapiclient.discovery.build(
40+
serviceName='iam', version='v1', http=http_auth)
4041

4142
now = int(time.time())
4243

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
gunicorn==19.6.0
2-
oauth2client==4.0.0
32
kinto==5.3.5
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
Flask==0.12
22
google-cloud-pubsub==0.22.0
33
gunicorn==19.6.0
4-
oauth2client==4.0.0

appengine/standard/bigquery/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import json
2525
import os
2626

27-
from googleapiclient.discovery import build
27+
import googleapiclient.discovery
2828
from oauth2client.contrib.appengine import OAuth2DecoratorFromClientSecrets
2929
import webapp2
3030

@@ -38,7 +38,7 @@
3838
scope='https://www.googleapis.com/auth/bigquery')
3939

4040
# Create the bigquery api client
41-
service = build('bigquery', 'v2')
41+
service = googleapiclient.discovery.build('bigquery', 'v2')
4242

4343

4444
class MainPage(webapp2.RequestHandler):

appengine/standard/storage/api-client/main.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,15 @@
2525
import json
2626
import StringIO
2727

28-
from googleapiclient import discovery
29-
from googleapiclient import http
30-
from oauth2client.client import GoogleCredentials
28+
import googleapiclient.discovery
29+
import googleapiclient.http
3130
import webapp2
3231

3332

3433
# The bucket that will be used to list objects.
3534
BUCKET_NAME = '<your-bucket-name>'
3635

37-
credentials = GoogleCredentials.get_application_default()
38-
storage = discovery.build('storage', 'v1', credentials=credentials)
36+
storage = googleapiclient.discovery.build('storage', 'v1')
3937

4038

4139
class MainPage(webapp2.RequestHandler):
@@ -44,7 +42,8 @@ def upload_object(self, bucket, file_object):
4442
'name': 'storage-api-client-sample-file.txt',
4543
}
4644
req = storage.objects().insert(
47-
bucket=bucket, body=body, media_body=http.MediaIoBaseUpload(
45+
bucket=bucket, body=body,
46+
media_body=googleapiclient.http.MediaIoBaseUpload(
4847
file_object, 'application/octet-stream'))
4948
resp = req.execute()
5049
return resp

bigquery/api/async_query.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
import time
2424
import uuid
2525

26-
from googleapiclient import discovery
27-
from oauth2client.client import GoogleCredentials
26+
import googleapiclient.discovery
2827

2928

3029
# [START async_query]
@@ -82,11 +81,8 @@ def main(
8281
project_id, query_string, batch, num_retries, interval,
8382
use_legacy_sql):
8483
# [START build_service]
85-
# Grab the application's default credentials from the environment.
86-
credentials = GoogleCredentials.get_application_default()
87-
8884
# Construct the service object for interacting with the BigQuery API.
89-
bigquery = discovery.build('bigquery', 'v2', credentials=credentials)
85+
bigquery = googleapiclient.discovery.build('bigquery', 'v2')
9086
# [END build_service]
9187

9288
# Submit the job and wait for it to complete.

bigquery/api/export_data_to_cloud_storage.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
import time
2828
import uuid
2929

30-
from googleapiclient import discovery
31-
from oauth2client.client import GoogleCredentials
30+
import googleapiclient.discovery
3231

3332

3433
# [START export_table]
@@ -107,11 +106,8 @@ def poll_job(bigquery, job):
107106
def main(cloud_storage_path, project_id, dataset_id, table_id,
108107
num_retries, interval, export_format="CSV", compression="NONE"):
109108
# [START build_service]
110-
# Grab the application's default credentials from the environment.
111-
credentials = GoogleCredentials.get_application_default()
112-
113109
# Construct the service object for interacting with the BigQuery API.
114-
bigquery = discovery.build('bigquery', 'v2', credentials=credentials)
110+
bigquery = googleapiclient.discovery.build('bigquery', 'v2')
115111
# [END build_service]
116112

117113
job = export_table(

bigquery/api/getting_started.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,14 @@
2727
# [START all]
2828
import argparse
2929

30-
from googleapiclient.discovery import build
30+
import googleapiclient.discovery
3131
from googleapiclient.errors import HttpError
32-
from oauth2client.client import GoogleCredentials
3332

3433

3534
def main(project_id):
3635
# [START build_service]
37-
# Grab the application's default credentials from the environment.
38-
credentials = GoogleCredentials.get_application_default()
3936
# Construct the service object for interacting with the BigQuery API.
40-
bigquery_service = build('bigquery', 'v2', credentials=credentials)
37+
bigquery_service = googleapiclient.discovery.build('bigquery', 'v2')
4138
# [END build_service]
4239

4340
try:

bigquery/api/installed_app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import argparse
2828
import pprint
2929

30-
from googleapiclient import discovery
30+
import googleapiclient.discovery
3131
from googleapiclient.errors import HttpError
3232
from oauth2client import tools
3333
from oauth2client.client import AccessTokenRefreshError
@@ -51,7 +51,7 @@ def main(args):
5151
credentials = tools.run_flow(flow, storage, args)
5252

5353
# Create a BigQuery client using the credentials.
54-
bigquery_service = discovery.build(
54+
bigquery_service = googleapiclient.discovery.build(
5555
'bigquery', 'v2', credentials=credentials)
5656

5757
# List all datasets in BigQuery

0 commit comments

Comments
 (0)