From 67590f67f875c6085359777ddd57d68c424b99cd Mon Sep 17 00:00:00 2001 From: Jerjou Cheng Date: Thu, 13 Aug 2015 15:57:51 -0700 Subject: [PATCH] Make authn sample more uniform with the java one. --- bigquery/samples/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bigquery/samples/utils.py b/bigquery/samples/utils.py index 53d26d0c6471..59a0240a77ed 100644 --- a/bigquery/samples/utils.py +++ b/bigquery/samples/utils.py @@ -21,9 +21,16 @@ def get_service(): from oauth2client.client import GoogleCredentials credentials = GoogleCredentials.get_application_default() + + # Some credential types require you to specify scopes, and service entry + # points may not inject them. Check for this case, and inject the scopes + # explicitly if required. if credentials.create_scoped_required(): credentials = credentials.create_scoped( 'https://www.googleapis.com/auth/bigquery') + + # Otherwise, the build() method takes care of injecting the proper scopes + # for the given service. return build('bigquery', 'v2', credentials=credentials) # [END get_service]