From 3b6f60b3d28a086174aedab0873d80cea68bee55 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Thu, 2 Apr 2020 00:56:18 +0000 Subject: [PATCH 1/5] chore: remove oauth2client from functions and iot --- functions/billing/main.py | 6 +----- functions/billing/requirements.txt | 1 - functions/slack/requirements.txt | 1 - .../end_to_end_example/cloudiot_pubsub_example_server.py | 6 +++--- iot/api-client/end_to_end_example/requirements.txt | 1 - iot/api-client/manager/requirements.txt | 1 - 6 files changed, 4 insertions(+), 12 deletions(-) diff --git a/functions/billing/main.py b/functions/billing/main.py index 9f5c5069bb0..9d0a10e4ae9 100644 --- a/functions/billing/main.py +++ b/functions/billing/main.py @@ -26,7 +26,6 @@ # [START functions_billing_limit_appengine] # [START functions_billing_stop] from googleapiclient import discovery -from oauth2client.client import GoogleCredentials # [END functions_billing_stop] # [END functions_billing_limit] # [END functions_billing_limit_appengine] @@ -80,7 +79,6 @@ def stop_billing(data, context): 'cloudbilling', 'v1', cache_discovery=False, - credentials=GoogleCredentials.get_application_default() ) projects = billing.projects() @@ -130,7 +128,6 @@ def limit_use(data, context): 'compute', 'v1', cache_discovery=False, - credentials=GoogleCredentials.get_application_default() ) instances = compute.instances() @@ -190,8 +187,7 @@ def limit_use_appengine(data, context): appengine = discovery.build( 'appengine', 'v1', - cache_discovery=False, - credentials=GoogleCredentials.get_application_default() + cache_discovery=False ) apps = appengine.apps() diff --git a/functions/billing/requirements.txt b/functions/billing/requirements.txt index b7c54be587d..ccde2ed93d5 100644 --- a/functions/billing/requirements.txt +++ b/functions/billing/requirements.txt @@ -1,5 +1,4 @@ slackclient==2.5.0 # [START functions_billing_limit_appengine_deps] -oauth2client==4.1.3 google-api-python-client==1.7.11 # [START functions_billing_limit_appengine_deps] \ No newline at end of file diff --git a/functions/slack/requirements.txt b/functions/slack/requirements.txt index 531c3121b64..6fc04a641f6 100644 --- a/functions/slack/requirements.txt +++ b/functions/slack/requirements.txt @@ -1,4 +1,3 @@ google-api-python-client==1.7.11 flask==1.1.1 -oauth2client==4.1.3 slackeventsapi==2.1.0 diff --git a/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py b/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py index cbac82869bb..8b0db992583 100644 --- a/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py +++ b/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py @@ -45,7 +45,7 @@ from google.cloud import pubsub from googleapiclient import discovery from googleapiclient.errors import HttpError -from oauth2client.service_account import ServiceAccountCredentials +from gogole.auth import service_account API_SCOPES = ['https://www.googleapis.com/auth/cloud-platform'] @@ -58,8 +58,8 @@ class Server(object): """Represents the state of the server.""" def __init__(self, service_account_json): - credentials = ServiceAccountCredentials.from_json_keyfile_name( - service_account_json, API_SCOPES) + credentials = service_account.from_service_account_file( + service_account_json, API_SCOPES).with_scopes(API_SCOPES) if not credentials: sys.exit('Could not load service account credential ' 'from {}'.format(service_account_json)) diff --git a/iot/api-client/end_to_end_example/requirements.txt b/iot/api-client/end_to_end_example/requirements.txt index e828bbcd011..5a438c5490b 100644 --- a/iot/api-client/end_to_end_example/requirements.txt +++ b/iot/api-client/end_to_end_example/requirements.txt @@ -3,6 +3,5 @@ google-api-python-client==1.7.11 google-auth-httplib2==0.0.3 google-auth==1.11.2 google-cloud-pubsub==1.1.0 -oauth2client==4.1.3 pyjwt==1.7.1 paho-mqtt==1.5.0 diff --git a/iot/api-client/manager/requirements.txt b/iot/api-client/manager/requirements.txt index cb7e7e6fbf3..57e32880a91 100644 --- a/iot/api-client/manager/requirements.txt +++ b/iot/api-client/manager/requirements.txt @@ -5,6 +5,5 @@ google-auth-httplib2==0.0.3 google-auth==1.11.2 google-cloud-iot==1.0.0 google-cloud-pubsub==1.1.0 -oauth2client==4.1.3 paho-mqtt==1.5.0 pyjwt==1.7.1 From 4f129d23e50cb1d233df25d1efb7ff68d63c4c4a Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Thu, 2 Apr 2020 00:59:20 +0000 Subject: [PATCH 2/5] fix: fix import --- .../end_to_end_example/cloudiot_pubsub_example_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py b/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py index 8b0db992583..ceeb42a6c04 100644 --- a/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py +++ b/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py @@ -45,7 +45,7 @@ from google.cloud import pubsub from googleapiclient import discovery from googleapiclient.errors import HttpError -from gogole.auth import service_account +from google.auth import service_account API_SCOPES = ['https://www.googleapis.com/auth/cloud-platform'] From 472c18542d1a15df8b2cf3eb19e883e1581b8a4a Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Thu, 2 Apr 2020 00:59:58 +0000 Subject: [PATCH 3/5] fix: correct syntax --- .../end_to_end_example/cloudiot_pubsub_example_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py b/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py index ceeb42a6c04..8aa8653a25f 100644 --- a/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py +++ b/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py @@ -59,7 +59,7 @@ class Server(object): def __init__(self, service_account_json): credentials = service_account.from_service_account_file( - service_account_json, API_SCOPES).with_scopes(API_SCOPES) + service_account_json).with_scopes(API_SCOPES) if not credentials: sys.exit('Could not load service account credential ' 'from {}'.format(service_account_json)) From 79f1a205c69aacfd4dd2deac792d7dc0f2289ddd Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Thu, 2 Apr 2020 16:43:20 +0000 Subject: [PATCH 4/5] fix: correct import for service_account --- .../end_to_end_example/cloudiot_pubsub_example_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py b/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py index 8aa8653a25f..0ea23375b89 100644 --- a/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py +++ b/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py @@ -45,7 +45,7 @@ from google.cloud import pubsub from googleapiclient import discovery from googleapiclient.errors import HttpError -from google.auth import service_account +from google.oauth2 import service_account API_SCOPES = ['https://www.googleapis.com/auth/cloud-platform'] From 07d845c03b9b277bfbc072f7764226bfffe7c3d1 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Fri, 3 Apr 2020 14:41:37 -0700 Subject: [PATCH 5/5] fix: fix path --- .../end_to_end_example/cloudiot_pubsub_example_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py b/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py index 0ea23375b89..c04a2b9e1af 100644 --- a/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py +++ b/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py @@ -58,7 +58,7 @@ class Server(object): """Represents the state of the server.""" def __init__(self, service_account_json): - credentials = service_account.from_service_account_file( + credentials = service_account.Credentials.from_service_account_file( service_account_json).with_scopes(API_SCOPES) if not credentials: sys.exit('Could not load service account credential '