Commit 83ca7a6e authored by Thomas Stone's avatar Thomas Stone
Browse files

we got the pickle back!

parent fb0db627
runtime: python39 runtime: python39
api_version: 1
threadsafe: true handlers:
handlers:- - url: /static
url: /static static_dir: static
static_dir: static-
url: /.* - url: /.*
script: webserver.py script: auto
libraries: - \ No newline at end of file
name: ssl
version: latest
\ No newline at end of file
import datetime import datetime
import pickle import pickle
import os.path import os.path
from webbrowser import get
from googleapiclient.discovery import build from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request from google.auth.transport.requests import Request
...@@ -32,4 +33,7 @@ def get_calendar_service(): ...@@ -32,4 +33,7 @@ def get_calendar_service():
pickle.dump(creds, token) pickle.dump(creds, token)
service = build('calendar', 'v3', credentials=creds) service = build('calendar', 'v3', credentials=creds)
return service return service
\ No newline at end of file
if __name__ == '__main__':
get_calendar_service()
\ No newline at end of file
{"web":{"client_id":"259120833380-733br30ukc4vuotg505hlc792e4i94tk.apps.googleusercontent.com","project_id":"bucknellschedule","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["https://localhost"]}} {"web":{"client_id":"259120833380-a71hd47n7sphnkvisqng0bfrftiootoq.apps.googleusercontent.com","project_id":"bucknellschedule","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["http://localhost:53309/"]}}
\ No newline at end of file \ No newline at end of file
import datetime
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/calendar']
CREDENTIALS_FILE = 'credentials.json'
def get_calendar_service():
creds = None
# The file token.pickle stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
CREDENTIALS_FILE, SCOPES)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run
with open('token.pickle', 'wb') as token:
pickle.dump(creds, token)
service = build('calendar', 'v3', credentials=creds)
return service
if __name__ == '__main__':
service = get_calendar_service()
# Call the Calendar API
print('Getting list of calendars')
calendars_result = service.calendarList().list().execute()
calendars = calendars_result.get('items', [])
if not calendars:
print('No calendars found.')
for calendar in calendars:
summary = calendar['summary']
id = calendar['id']
primary = "Primary" if calendar.get('primary') else ""
print("%s\t%s\t%s" % (summary, id, primary))
\ No newline at end of file
No preview for this file type
.generate_schedule_btn { #generate_schedule_btn {
margin: 1em; margin: 1em;
appearance: none; appearance: none;
background-color: #2e8ca4; background-color: #2e8ca4;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
border-radius: 6px; border-radius: 6px;
box-shadow: rgba(27, 31, 35, .1) 0 1px 0; box-shadow: rgba(27, 31, 35, .1) 0 1px 0;
box-sizing: border-box; box-sizing: border-box;
color: #2e8ca4; color: white;
cursor: pointer; cursor: pointer;
display: inline-block; display: inline-block;
padding: 14px 16px; padding: 14px 16px;
...@@ -17,28 +17,28 @@ ...@@ -17,28 +17,28 @@
white-space: nowrap; white-space: nowrap;
} }
.generate_schedule_btn:focus:not(:focus-visible):not(.focus-visible) { #generate_schedule_btn:focus:not(:focus-visible):not(.focus-visible) {
box-shadow: none; box-shadow: none;
outline: none; outline: none;
} }
.generate_schedule_btn:hover { #generate_schedule_btn:hover {
background-color: #2e7fa4; background-color: #2e7fa4;
} }
.generate_schedule_btn:focus { #generate_schedule_btn:focus {
box-shadow: rgba(46, 164, 79, .4) 0 0 0 3px; box-shadow: rgba(46, 164, 79, .4) 0 0 0 3px;
outline: none; outline: none;
} }
.generate_schedule_btn:disabled { #generate_schedule_btn:disabled {
background-color: #94d3a2; background-color: #94d3a2;
border-color: rgba(27, 31, 35, .1); border-color: rgba(27, 31, 35, .1);
color: rgba(255, 255, 255, .8); color: rgba(255, 255, 255, .8);
cursor: default; cursor: default;
} }
.generate_schedule_btn:active { #generate_schedule_btn:active {
background-color: #2e75a4; background-color: #2e75a4;
box-shadow: rgba(20, 70, 32, .2) 0 1px 0 inset; box-shadow: rgba(20, 70, 32, .2) 0 1px 0 inset;
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment