From ae83efbc73679119acae6ec8505e193811b778b6 Mon Sep 17 00:00:00 2001 From: Craig Citro Date: Fri, 6 Jun 2014 09:45:57 -0700 Subject: [PATCH] Check credentials types before using them. We previously used methods from oauth2client.client.GoogleCredentials on an object that might only be an instance of oauth2client.client.Credentials. --- googleapiclient/discovery.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/googleapiclient/discovery.py b/googleapiclient/discovery.py index 53ff9450117..6385ea98091 100644 --- a/googleapiclient/discovery.py +++ b/googleapiclient/discovery.py @@ -63,6 +63,7 @@ from googleapiclient.model import RawModel from googleapiclient.schema import Schemas from oauth2client.anyjson import simplejson +from oauth2client.client import GoogleCredentials from oauth2client.util import _add_query_parameter from oauth2client.util import positional @@ -263,8 +264,9 @@ def build_from_document( # to be used). In this case, the Default Credentials are built and # used instead of the original credentials. If there are no scopes # found (meaning the given service requires no authentication), there is - # no authorization of the http. - if credentials.create_scoped_required(): + # no authorization of the http. + if (isinstance(credentials, GoogleCredentials) and + credentials.create_scoped_required()): scopes = service.get('auth', {}).get('oauth2', {}).get('scopes', {}) if scopes: credentials = credentials.create_scoped(scopes.keys())