Skip to content

Commit 3154286

Browse files
author
Eric Koleda
committed
Merge branch 'master' into main
2 parents fa5943d + 4c2120d commit 3154286

File tree

23 files changed

+215
-158
lines changed

23 files changed

+215
-158
lines changed

.pylintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,3 +424,6 @@ max-public-methods=50
424424
# Exceptions that will emit a warning when being caught. Defaults to
425425
# "Exception"
426426
overgeneral-exceptions=Exception
427+
428+
# Python 2/3 compatibility
429+
disable=useless-object-inheritance

admin_sdk/directory/quickstart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from __future__ import print_function
1717
from apiclient.discovery import build
1818
from httplib2 import Http
19-
from oauth2client import file, client, tools
19+
from oauth2client import file as oauth_file, client, tools
2020

2121
# If modifying these scopes, delete the file token.json.
2222
SCOPES = 'https://www.googleapis.com/auth/admin.directory.user'
@@ -27,7 +27,7 @@ def main():
2727
2828
Prints the emails and names of the first 10 users in the domain.
2929
"""
30-
store = file.Storage('token.json')
30+
store = oauth_file.Storage('token.json')
3131
creds = store.get()
3232
if not creds or creds.invalid:
3333
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)

admin_sdk/reports/quickstart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from __future__ import print_function
1717
from apiclient.discovery import build
1818
from httplib2 import Http
19-
from oauth2client import file, client, tools
19+
from oauth2client import file as oauth_file, client, tools
2020

2121
# If modifying these scopes, delete the file token.json.
2222
SCOPES = 'https://www.googleapis.com/auth/admin.reports.audit.readonly'
@@ -27,7 +27,7 @@ def main():
2727
2828
Prints the time, email, and name of the last 10 login events in the domain.
2929
"""
30-
store = file.Storage('token.json')
30+
store = oauth_file.Storage('token.json')
3131
creds = store.get()
3232
if not creds or creds.invalid:
3333
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)

admin_sdk/reseller/quickstart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from __future__ import print_function
2121
from apiclient.discovery import build
2222
from httplib2 import Http
23-
from oauth2client import file, client, tools
23+
from oauth2client import file as oauth_file, client, tools
2424

2525
# If modifying these scopes, delete the file token.json.
2626
SCOPES = 'https://www.googleapis.com/auth/apps.order'
@@ -29,7 +29,7 @@
2929
def main():
3030
"""Calls the Admin SDK Reseller API.
3131
"""
32-
store = file.Storage('token.json')
32+
store = oauth_file.Storage('token.json')
3333
creds = store.get()
3434
if not creds or creds.invalid:
3535
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)

apps_script/execute/execute.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,25 @@
1313
# limitations under the License.
1414

1515
# [START apps_script_execute]
16+
from __future__ import print_function
17+
from apiclient import errors
18+
from apiclient.discovery import build
19+
from httplib2 import Http
20+
from oauth2client import file as oauth_file, client, tools
21+
1622
def main():
1723
"""Runs the sample.
1824
"""
1925
SCRIPT_ID = 'ENTER_YOUR_SCRIPT_ID_HERE'
2026

21-
# Authorize and create a service object.
22-
credentials = get_credentials()
23-
http = credentials.authorize(httplib2.Http())
24-
service = discovery.build('script', 'v1', http=http)
27+
# Setup the Apps Script API
28+
SCOPES = 'https://www.googleapis.com/auth/script.projects'
29+
store = oauth_file.Storage('token.json')
30+
creds = store.get()
31+
if not creds or creds.invalid:
32+
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
33+
creds = tools.run_flow(flow, store)
34+
service = build('script', 'v1', http=creds.authorize(Http()))
2535

2636
# Create an execution request object.
2737
request = {"function": "getFoldersUnderRoot"}

apps_script/quickstart/quickstart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from apiclient import errors
2323
from apiclient.discovery import build
2424
from httplib2 import Http
25-
from oauth2client import file, client, tools
25+
from oauth2client import file as oauth_file, client, tools
2626

2727
# If modifying these scopes, delete the file token.json.
2828
SCOPES = 'https://www.googleapis.com/auth/script.projects'
@@ -44,7 +44,7 @@
4444
def main():
4545
"""Calls the Apps Script API.
4646
"""
47-
store = file.Storage('token.json')
47+
store = oauth_file.Storage('token.json')
4848
creds = store.get()
4949
if not creds or creds.invalid:
5050
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)

calendar/quickstart/quickstart.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
# [START calendar_quickstart]
1616
from __future__ import print_function
17+
import datetime
1718
from apiclient.discovery import build
1819
from httplib2 import Http
19-
from oauth2client import file, client, tools
20-
import datetime
20+
from oauth2client import file as oauth_file, client, tools
2121

2222
# If modifying these scopes, delete the file token.json.
2323
SCOPES = 'https://www.googleapis.com/auth/calendar.readonly'
@@ -28,7 +28,7 @@ def main():
2828
2929
Prints the start and name of the next 10 events on the user's calendar.
3030
"""
31-
store = file.Storage('token.json')
31+
store = oauth_file.Storage('token.json')
3232
creds = store.get()
3333
if not creds or creds.invalid:
3434
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)

classroom/quickstart/quickstart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from __future__ import print_function
1717
from apiclient.discovery import build
1818
from httplib2 import Http
19-
from oauth2client import file, client, tools
19+
from oauth2client import file as oauth_file, client, tools
2020

2121
# If modifying these scopes, delete the file token.json.
2222
SCOPES = 'https://www.googleapis.com/auth/classroom.courses.readonly'
@@ -27,7 +27,7 @@ def main():
2727
2828
Prints the names of the first 10 courses the user has access to.
2929
"""
30-
store = file.Storage('token.json')
30+
store = oauth_file.Storage('token.json')
3131
creds = store.get()
3232
if not creds or creds.invalid:
3333
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)

drive/activity/quickstart.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
# [START drive_activity_quickstart]
1616
from __future__ import print_function
17+
import datetime
1718
from apiclient.discovery import build
1819
from httplib2 import Http
19-
from oauth2client import file, client, tools
20-
import datetime
20+
from oauth2client import file as oauth_file, client, tools
2121

2222
# If modifying these scopes, delete the file token.json.
2323
SCOPES = 'https://www.googleapis.com/auth/activity'
@@ -28,7 +28,7 @@ def main():
2828
2929
Prints information about the last 10 events that occured the user's Drive.
3030
"""
31-
store = file.Storage('token.json')
31+
store = oauth_file.Storage('token.json')
3232
creds = store.get()
3333
if not creds or creds.invalid:
3434
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)

drive/driveapp/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
This script uploads a single file to Google Drive.
66
"""
77

8+
from __future__ import print_function
89
import pprint
9-
1010
import httplib2
1111
import apiclient.discovery
1212
import apiclient.http
@@ -31,8 +31,8 @@
3131
flow = oauth2client.client.flow_from_clientsecrets(CLIENT_SECRETS, OAUTH2_SCOPE)
3232
flow.redirect_uri = oauth2client.client.OOB_CALLBACK_URN
3333
authorize_url = flow.step1_get_authorize_url()
34-
print 'Go to the following link in your browser: ' + authorize_url
35-
code = raw_input('Enter verification code: ').strip()
34+
print('Go to the following link in your browser: ' + authorize_url)
35+
code = input('Enter verification code: ').strip()
3636
credentials = flow.step2_exchange(code)
3737

3838
# Create an authorized Drive API client.
@@ -54,5 +54,6 @@
5454
}
5555

5656
# Perform the request and print the result.
57-
new_file = drive_service.files().insert(body=body, media_body=media_body).execute()
57+
new_file = drive_service.files().insert(
58+
body=body, media_body=media_body).execute()
5859
pprint.pprint(new_file)

0 commit comments

Comments
 (0)