Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 89840a0

Browse files
authored
Remove oauth2client from IoT and Functions samples (GoogleCloudPlatform#3255)
* chore: remove oauth2client from functions and iot * fix: fix import * fix: correct syntax * fix: correct import for service_account * fix: fix path
1 parent ba4d402 commit 89840a0

File tree

6 files changed

+4
-12
lines changed

6 files changed

+4
-12
lines changed

functions/billing/main.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
# [START functions_billing_limit_appengine]
2727
# [START functions_billing_stop]
2828
from googleapiclient import discovery
29-
from oauth2client.client import GoogleCredentials
3029
# [END functions_billing_stop]
3130
# [END functions_billing_limit]
3231
# [END functions_billing_limit_appengine]
@@ -80,7 +79,6 @@ def stop_billing(data, context):
8079
'cloudbilling',
8180
'v1',
8281
cache_discovery=False,
83-
credentials=GoogleCredentials.get_application_default()
8482
)
8583

8684
projects = billing.projects()
@@ -130,7 +128,6 @@ def limit_use(data, context):
130128
'compute',
131129
'v1',
132130
cache_discovery=False,
133-
credentials=GoogleCredentials.get_application_default()
134131
)
135132
instances = compute.instances()
136133

@@ -190,8 +187,7 @@ def limit_use_appengine(data, context):
190187
appengine = discovery.build(
191188
'appengine',
192189
'v1',
193-
cache_discovery=False,
194-
credentials=GoogleCredentials.get_application_default()
190+
cache_discovery=False
195191
)
196192
apps = appengine.apps()
197193

functions/billing/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
slackclient==2.5.0
22
# [START functions_billing_limit_appengine_deps]
3-
oauth2client==4.1.3
43
google-api-python-client==1.7.11
54
# [START functions_billing_limit_appengine_deps]

functions/slack/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
google-api-python-client==1.7.11
22
flask==1.1.1
3-
oauth2client==4.1.3
43
slackeventsapi==2.1.0

iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
from google.cloud import pubsub
4646
from googleapiclient import discovery
4747
from googleapiclient.errors import HttpError
48-
from oauth2client.service_account import ServiceAccountCredentials
48+
from google.oauth2 import service_account
4949

5050

5151
API_SCOPES = ['https://www.googleapis.com/auth/cloud-platform']
@@ -58,8 +58,8 @@ class Server(object):
5858
"""Represents the state of the server."""
5959

6060
def __init__(self, service_account_json):
61-
credentials = ServiceAccountCredentials.from_json_keyfile_name(
62-
service_account_json, API_SCOPES)
61+
credentials = service_account.Credentials.from_service_account_file(
62+
service_account_json).with_scopes(API_SCOPES)
6363
if not credentials:
6464
sys.exit('Could not load service account credential '
6565
'from {}'.format(service_account_json))

iot/api-client/end_to_end_example/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ google-api-python-client==1.7.11
33
google-auth-httplib2==0.0.3
44
google-auth==1.11.2
55
google-cloud-pubsub==1.1.0
6-
oauth2client==4.1.3
76
pyjwt==1.7.1
87
paho-mqtt==1.5.0

iot/api-client/manager/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ google-auth-httplib2==0.0.3
55
google-auth==1.11.2
66
google-cloud-iot==1.0.0
77
google-cloud-pubsub==1.1.0
8-
oauth2client==4.1.3
98
paho-mqtt==1.5.0
109
pyjwt==1.7.1

0 commit comments

Comments
 (0)