Initial commit
This commit is contained in:
20
services/google.py
Normal file
20
services/google.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import httplib2
|
||||
import googleapiclient.discovery
|
||||
from oauth2client.service_account import ServiceAccountCredentials
|
||||
|
||||
from config import CREDENTIALS_FILE, SPREADSHEET_ID
|
||||
|
||||
|
||||
def get_google_service():
|
||||
credentials = ServiceAccountCredentials.from_json_keyfile_name(
|
||||
CREDENTIALS_FILE,
|
||||
[
|
||||
"https://www.googleapis.com/auth/spreadsheets",
|
||||
"https://www.googleapis.com/auth/drive",
|
||||
],
|
||||
)
|
||||
|
||||
http = credentials.authorize(httplib2.Http())
|
||||
return googleapiclient.discovery.build(
|
||||
"sheets", "v4", http=http, cache_discovery=False
|
||||
)
|
||||
Reference in New Issue
Block a user