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

Skip to content

Commit 17a40f9

Browse files
Merge pull request googleapis#182 from adrian-the-git/master
Fix incompatibility with oauth2client v2.0.0.
2 parents d83246e + 2122d3c commit 17a40f9

File tree

7 files changed

+18
-22
lines changed

7 files changed

+18
-22
lines changed

googleapiclient/discovery_cache/file_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import tempfile
3030
import threading
3131

32-
from oauth2client.locked_file import LockedFile
32+
from oauth2client.contrib.locked_file import LockedFile
3333

3434
from . import base
3535
from ..discovery_cache import DISCOVERY_DOC_MAX_AGE

samples/appengine/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
import pickle
3232

3333
from googleapiclient import discovery
34-
from oauth2client import appengine
3534
from oauth2client import client
35+
from oauth2client.contrib import appengine
3636
from google.appengine.api import memcache
3737

3838
import webapp2

samples/django_sample/plus/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from django.contrib.auth.models import User
66
from django.db import models
77

8-
from oauth2client.django_orm import FlowField
9-
from oauth2client.django_orm import CredentialsField
8+
from oauth2client.contrib.django_orm import FlowField
9+
from oauth2client.contrib.django_orm import CredentialsField
1010

1111

1212
class CredentialsModel(models.Model):

samples/django_sample/plus/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from django_sample import settings
1414
from oauth2client import xsrfutil
1515
from oauth2client.client import flow_from_clientsecrets
16-
from oauth2client.django_orm import Storage
16+
from oauth2client.contrib.django_orm import Storage
1717

1818
# CLIENT_SECRETS, name of a file containing the OAuth 2.0 information for this
1919
# application, including client_id and client_secret, which are found

samples/service_account/tasks.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,19 @@
3434
import sys
3535

3636
from googleapiclient.discovery import build
37-
from oauth2client.client import SignedJwtAssertionCredentials
37+
from oauth2client.service_account import ServiceAccountCredentials
3838

3939
def main(argv):
40-
# Load the key in PKCS 12 format that you downloaded from the Google API
41-
# Console when you created your Service account.
42-
f = file('key.p12', 'rb')
43-
key = f.read()
44-
f.close()
45-
46-
# Create an httplib2.Http object to handle our HTTP requests and authorize it
47-
# with the Credentials. Note that the first parameter, service_account_name,
48-
# is the Email address created for the Service account. It must be the email
49-
# address associated with the key that was created.
50-
credentials = SignedJwtAssertionCredentials(
51-
52-
key,
53-
scope='https://www.googleapis.com/auth/tasks')
40+
# Load the json format key that you downloaded from the Google API
41+
# Console when you created your service account. For p12 keys, use the
42+
# from_p12_keyfile method of ServiceAccountCredentials and specify the
43+
# service account email address, p12 keyfile, and scopes.
44+
credentials = ServiceAccountCredentials.from_json_keyfile_name(
45+
'service-account-abcdef123456.json',
46+
scopes='https://www.googleapis.com/auth/tasks')
47+
48+
# Create an httplib2.Http object to handle our HTTP requests and authorize
49+
# it with the Credentials.
5450
http = httplib2.Http()
5551
http = credentials.authorize(http)
5652

samples/storage_serviceaccount_appengine/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
from google.appengine.ext import webapp
4646
from google.appengine.ext.webapp import template
4747
from google.appengine.ext.webapp.util import run_wsgi_app
48-
from oauth2client.appengine import AppAssertionCredentials
48+
from oauth2client.contrib.appengine import AppAssertionCredentials
4949

5050
# Constants for the XSL stylesheet and the Google Cloud Storage URI.
5151
XSL = '\n<?xml-stylesheet href="/listing.xsl" type="text/xsl"?>\n';

samples/tasks_appengine/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from webapp2_extras import jinja2
1717

1818
from googleapiclient.discovery import build
19-
from oauth2client.appengine import OAuth2Decorator
19+
from oauth2client.contrib.appengine import OAuth2Decorator
2020

2121
import settings
2222

0 commit comments

Comments
 (0)