migrate to google-auth from oauth2client

This commit is contained in:
Dmitry Belyaev 2018-07-12 13:30:37 +03:00
parent d11f057381
commit 5afb97b634
Signed by: b4tman
GPG Key ID: 014E87EC54B77673
2 changed files with 10 additions and 11 deletions

View File

@ -1,10 +1,11 @@
from apiclient import discovery
import httplib2
import logging
from oauth2client import service_account
from pytz import utc
import sys
import google.auth
from google.oauth2 import service_account
from googleapiclient import discovery
from pytz import utc
class GoogleCalendarService():
"""class for make google calendar service Resource
@ -21,14 +22,12 @@ class GoogleCalendarService():
service Resource
"""
scopes = 'https://www.googleapis.com/auth/calendar'
credentials = service_account.ServiceAccountCredentials.from_json_keyfile_name(
service_account_file, scopes=scopes)
http = credentials.authorize(httplib2.Http())
service = discovery.build('calendar', 'v3', http=http)
scopes = ['https://www.googleapis.com/auth/calendar']
credentials = service_account.Credentials.from_service_account_file(service_account_file)
scoped_credentials = credentials.with_scopes(scopes)
service = discovery.build('calendar', 'v3', credentials=scoped_credentials)
return service
def select_event_key(event):
"""select event key for logging

View File

@ -1,4 +1,4 @@
oauth2client==4.1.2
google-auth-1.5.0
google-api-python-client==1.7.3
icalendar==4.0.2
pytz==2018.5