Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit f3dc0f3

Browse files
author
Jon Wayne Parrott
authored
Remove usage of GoogleCredentials [(#810)](GoogleCloudPlatform/python-docs-samples#810)
1 parent 514cafd commit f3dc0f3

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

samples/snippets/create_cluster_and_submit_job.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
import argparse
1717
import os
1818

19-
from apiclient import discovery
2019
from google.cloud import storage
21-
from oauth2client.client import GoogleCredentials
20+
import googleapiclient.discovery
2221

2322
# Currently only the "global" region is supported
2423
REGION = 'global'
@@ -177,8 +176,7 @@ def wait_for_job(dataproc, project, job_id):
177176
def get_client():
178177
"""Builds an http client authenticated with the service account
179178
credentials."""
180-
credentials = GoogleCredentials.get_application_default()
181-
dataproc = discovery.build('dataproc', 'v1', credentials=credentials)
179+
dataproc = googleapiclient.discovery.build('dataproc', 'v1')
182180
return dataproc
183181
# [END get_client]
184182

samples/snippets/list_clusters.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717
import argparse
1818

19-
from apiclient import discovery
20-
from oauth2client.client import GoogleCredentials
19+
import googleapiclient.discovery
2120

2221
# Currently only the "global" region is supported
2322
REGION = 'global'
@@ -34,10 +33,8 @@ def list_clusters(dataproc, project):
3433

3534
# [START get_client]
3635
def get_client():
37-
"""Builds an http client authenticated with the service account
38-
credentials."""
39-
credentials = GoogleCredentials.get_application_default()
40-
dataproc = discovery.build('dataproc', 'v1', credentials=credentials)
36+
"""Builds a client to the dataproc API."""
37+
dataproc = googleapiclient.discovery.build('dataproc', 'v1')
4138
return dataproc
4239
# [END get_client]
4340

0 commit comments

Comments
 (0)