Undo serialization using picke, added comment on minimum version for google-api-python-client
This commit is contained in:
parent
80efa64614
commit
2b3b9c0ca0
1 changed files with 4 additions and 6 deletions
|
@ -14,7 +14,7 @@ Parameters:
|
||||||
* gcalendar.locale: locale to use rather than the system default.
|
* gcalendar.locale: locale to use rather than the system default.
|
||||||
|
|
||||||
Requires these pip packages:
|
Requires these pip packages:
|
||||||
* google-api-python-client
|
* google-api-python-client >= 1.8.0
|
||||||
* google-auth-httplib2
|
* google-auth-httplib2
|
||||||
* google-auth-oauthlib
|
* google-auth-oauthlib
|
||||||
"""
|
"""
|
||||||
|
@ -30,7 +30,6 @@ import core.decorators
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import os.path
|
import os.path
|
||||||
import pickle
|
|
||||||
import locale
|
import locale
|
||||||
|
|
||||||
from google.auth.transport.requests import Request
|
from google.auth.transport.requests import Request
|
||||||
|
@ -72,8 +71,7 @@ class Module(core.module.Module):
|
||||||
# created automatically when the authorization flow completes for the first
|
# created automatically when the authorization flow completes for the first
|
||||||
# time.
|
# time.
|
||||||
if os.path.exists(self.__token):
|
if os.path.exists(self.__token):
|
||||||
with open(self.__token, 'rb') as token:
|
creds = Credentials.from_authorized_user_file(self.__token, SCOPES)
|
||||||
creds = pickle.load(token)
|
|
||||||
# If there are no (valid) credentials available, let the user log in.
|
# If there are no (valid) credentials available, let the user log in.
|
||||||
if not creds or not creds.valid:
|
if not creds or not creds.valid:
|
||||||
if creds and creds.expired and creds.refresh_token:
|
if creds and creds.expired and creds.refresh_token:
|
||||||
|
@ -84,8 +82,8 @@ class Module(core.module.Module):
|
||||||
)
|
)
|
||||||
creds = flow.run_local_server(port=0)
|
creds = flow.run_local_server(port=0)
|
||||||
# Save the credentials for the next run
|
# Save the credentials for the next run
|
||||||
with open(self.__token, 'wb') as token:
|
with open(self.__token, "w") as token:
|
||||||
pickle.dump(creds, token)
|
token.write(creds.to_json())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
service = build("calendar", "v3", credentials=creds)
|
service = build("calendar", "v3", credentials=creds)
|
||||||
|
|
Loading…
Reference in a new issue