Skip to content

Check credentials types before using them. #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions googleapiclient/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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())
Expand Down