adds privacy policy and page footer
This commit is contained in:
@ -68,7 +68,7 @@ def login():
|
||||
# for the OAuth 2.0 client, which you configured in the API Console. If this
|
||||
# value doesn't match an authorized URI, you will get a 'redirect_uri_mismatch'
|
||||
# error.
|
||||
flow.redirect_uri = request.base_url + "/callback"
|
||||
flow.redirect_uri = "https://longitudecalendar.com/login/google/callback"
|
||||
authorization_url, state = flow.authorization_url(
|
||||
# Enable offline access so that you can refresh an access token without
|
||||
# re-prompting the user for permission. Recommended for web server apps.
|
||||
@ -88,8 +88,8 @@ def verifyResponse():
|
||||
|
||||
flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
|
||||
GC.CLIENT_SECRETS_FILE, scopes=GC.SCOPES, state=state)
|
||||
flow.redirect_uri = flask.url_for('callback', _external=True)
|
||||
|
||||
flow.redirect_uri = "https://longitudecalendar.com/login/google/callback"
|
||||
|
||||
# Use the authorization server's response to fetch the OAuth 2.0 tokens.
|
||||
authorization_response = flask.request.url
|
||||
flow.fetch_token(authorization_response=authorization_response)
|
||||
@ -122,7 +122,7 @@ class Calendar:
|
||||
self.toggle=toggle
|
||||
self.calendarId = calendarId
|
||||
|
||||
# TODO move this to databas
|
||||
# TODO move this to database
|
||||
def calendarsFromDb():
|
||||
pyCalendars = []
|
||||
for calendar in current_user.calendars:
|
||||
@ -147,18 +147,14 @@ def updateCalendars():
|
||||
# print(a, flush=True)
|
||||
# print(current_user.getGoogleCredentials(), flush=True)
|
||||
if current_user.google_token == None:
|
||||
print("notok", flush=True)
|
||||
return
|
||||
|
||||
client_token = GC.build_credentials(current_user.google_token.token,
|
||||
current_user.google_token.refresh_token)
|
||||
credentials = google.oauth2.credentials.Credentials(**client_token)
|
||||
calendars = caltojson.getCalendarList(credentials)
|
||||
print(calendars, flush=True)
|
||||
for calendar in calendars:
|
||||
print(calendar, flush=True)
|
||||
if not current_user.hasCalendar(calendar.calendarId):
|
||||
print("adding", flush=True)
|
||||
c = dbCalendar(calendar_id=calendar.calendarId,
|
||||
name = calendar.summary,
|
||||
toggle = "False",
|
||||
@ -166,14 +162,12 @@ def updateCalendars():
|
||||
db.session.add(c)
|
||||
current_user.calendars.append(c)
|
||||
|
||||
db.session.commit()
|
||||
print("updated Calendars")
|
||||
# Save credentials back to session in case access token was refreshed.
|
||||
# ACTION ITEM: In a production app, you likely want to save these
|
||||
# credentials in a persistent database instead.
|
||||
# TODO add save updated token to database here
|
||||
flask.session['credentials'] = credentials_to_dict(credentials)
|
||||
|
||||
current_user.google_token.token = credentials.token
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def credentials_to_dict(credentials):
|
||||
|
Reference in New Issue
Block a user