Skip to content
This repository has been archived by the owner on Oct 17, 2022. It is now read-only.

Commit

Permalink
Use oauth2client authorize http with credentials feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Prin committed Nov 21, 2015
1 parent 5f3528f commit c77beb2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions cmdline-pull/pubsub_sample.py
Expand Up @@ -26,7 +26,6 @@
import time

from googleapiclient import discovery
import httplib2
from oauth2client.client import GoogleCredentials


Expand Down Expand Up @@ -328,9 +327,7 @@ def main(argv):
credentials = GoogleCredentials.get_application_default()
if credentials.create_scoped_required():
credentials = credentials.create_scoped(PUBSUB_SCOPES)
http = httplib2.Http()
credentials.authorize(http=http)
client = discovery.build('pubsub', 'v1', http=http)
client = discovery.build('pubsub', 'v1', credentials=credentials)

args = parser.parse_args(argv[1:])
args.func(client, args)
Expand Down
5 changes: 1 addition & 4 deletions gce-cmdline-publisher/traffic_pubsub_generator.py
Expand Up @@ -60,7 +60,6 @@

from apiclient import discovery
from dateutil.parser import parse
import httplib2
from oauth2client.client import GoogleCredentials

# default; set to your traffic topic. Can override on command line.
Expand Down Expand Up @@ -89,9 +88,7 @@ def create_pubsub_client():
credentials = GoogleCredentials.get_application_default()
if credentials.create_scoped_required():
credentials = credentials.create_scoped(PUBSUB_SCOPES)
http = httplib2.Http()
credentials.authorize(http)
return discovery.build('pubsub', 'v1beta2', http=http)
return discovery.build('pubsub', 'v1beta2', credentials=credentials)


def publish(client, pubsub_topic, data_line, msg_attributes=None):
Expand Down

0 comments on commit c77beb2

Please sign in to comment.