diff --git a/googleapiclient/discovery_cache/file_cache.py b/googleapiclient/discovery_cache/file_cache.py index ce540f02bd3..8b0301d2ff2 100644 --- a/googleapiclient/discovery_cache/file_cache.py +++ b/googleapiclient/discovery_cache/file_cache.py @@ -29,7 +29,7 @@ import tempfile import threading -from oauth2client.locked_file import LockedFile +from oauth2client.contrib.locked_file import LockedFile from . import base from ..discovery_cache import DISCOVERY_DOC_MAX_AGE diff --git a/samples/appengine/main.py b/samples/appengine/main.py index 3d8587bef2b..d2a3223a7f4 100644 --- a/samples/appengine/main.py +++ b/samples/appengine/main.py @@ -31,8 +31,8 @@ import pickle from googleapiclient import discovery -from oauth2client import appengine from oauth2client import client +from oauth2client.contrib import appengine from google.appengine.api import memcache import webapp2 diff --git a/samples/django_sample/plus/models.py b/samples/django_sample/plus/models.py index 890b2782866..6b9f762f87b 100644 --- a/samples/django_sample/plus/models.py +++ b/samples/django_sample/plus/models.py @@ -5,8 +5,8 @@ from django.contrib.auth.models import User from django.db import models -from oauth2client.django_orm import FlowField -from oauth2client.django_orm import CredentialsField +from oauth2client.contrib.django_orm import FlowField +from oauth2client.contrib.django_orm import CredentialsField class CredentialsModel(models.Model): diff --git a/samples/django_sample/plus/views.py b/samples/django_sample/plus/views.py index 1196cefdc6a..0699d96f5c6 100644 --- a/samples/django_sample/plus/views.py +++ b/samples/django_sample/plus/views.py @@ -13,7 +13,7 @@ from django_sample import settings from oauth2client import xsrfutil from oauth2client.client import flow_from_clientsecrets -from oauth2client.django_orm import Storage +from oauth2client.contrib.django_orm import Storage # CLIENT_SECRETS, name of a file containing the OAuth 2.0 information for this # application, including client_id and client_secret, which are found diff --git a/samples/service_account/tasks.py b/samples/service_account/tasks.py index 7de049dd0d5..43fc357e008 100644 --- a/samples/service_account/tasks.py +++ b/samples/service_account/tasks.py @@ -34,23 +34,19 @@ import sys from googleapiclient.discovery import build -from oauth2client.client import SignedJwtAssertionCredentials +from oauth2client.service_account import ServiceAccountCredentials def main(argv): - # Load the key in PKCS 12 format that you downloaded from the Google API - # Console when you created your Service account. - f = file('key.p12', 'rb') - key = f.read() - f.close() - - # Create an httplib2.Http object to handle our HTTP requests and authorize it - # with the Credentials. Note that the first parameter, service_account_name, - # is the Email address created for the Service account. It must be the email - # address associated with the key that was created. - credentials = SignedJwtAssertionCredentials( - '141491975384@developer.gserviceaccount.com', - key, - scope='https://www.googleapis.com/auth/tasks') + # Load the json format key that you downloaded from the Google API + # Console when you created your service account. For p12 keys, use the + # from_p12_keyfile method of ServiceAccountCredentials and specify the + # service account email address, p12 keyfile, and scopes. + credentials = ServiceAccountCredentials.from_json_keyfile_name( + 'service-account-abcdef123456.json', + scopes='https://www.googleapis.com/auth/tasks') + + # Create an httplib2.Http object to handle our HTTP requests and authorize + # it with the Credentials. http = httplib2.Http() http = credentials.authorize(http) diff --git a/samples/storage_serviceaccount_appengine/main.py b/samples/storage_serviceaccount_appengine/main.py index 59ae3252b04..21ec3f838e4 100644 --- a/samples/storage_serviceaccount_appengine/main.py +++ b/samples/storage_serviceaccount_appengine/main.py @@ -45,7 +45,7 @@ from google.appengine.ext import webapp from google.appengine.ext.webapp import template from google.appengine.ext.webapp.util import run_wsgi_app -from oauth2client.appengine import AppAssertionCredentials +from oauth2client.contrib.appengine import AppAssertionCredentials # Constants for the XSL stylesheet and the Google Cloud Storage URI. XSL = '\n\n'; diff --git a/samples/tasks_appengine/main.py b/samples/tasks_appengine/main.py index 9b0c8564b19..634f39c1ec0 100644 --- a/samples/tasks_appengine/main.py +++ b/samples/tasks_appengine/main.py @@ -16,7 +16,7 @@ from webapp2_extras import jinja2 from googleapiclient.discovery import build -from oauth2client.appengine import OAuth2Decorator +from oauth2client.contrib.appengine import OAuth2Decorator import settings