Skip to content

Commit ae83efb

Browse files
committed
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.
1 parent 44783ca commit ae83efb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

googleapiclient/discovery.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
from googleapiclient.model import RawModel
6464
from googleapiclient.schema import Schemas
6565
from oauth2client.anyjson import simplejson
66+
from oauth2client.client import GoogleCredentials
6667
from oauth2client.util import _add_query_parameter
6768
from oauth2client.util import positional
6869

@@ -263,8 +264,9 @@ def build_from_document(
263264
# to be used). In this case, the Default Credentials are built and
264265
# used instead of the original credentials. If there are no scopes
265266
# found (meaning the given service requires no authentication), there is
266-
# no authorization of the http.
267-
if credentials.create_scoped_required():
267+
# no authorization of the http.
268+
if (isinstance(credentials, GoogleCredentials) and
269+
credentials.create_scoped_required()):
268270
scopes = service.get('auth', {}).get('oauth2', {}).get('scopes', {})
269271
if scopes:
270272
credentials = credentials.create_scoped(scopes.keys())

0 commit comments

Comments
 (0)