Spaces:
Sleeping
Sleeping
Update app/services/google_docs.py
Browse files
app/services/google_docs.py
CHANGED
|
@@ -4,12 +4,15 @@ from googleapiclient.errors import HttpError
|
|
| 4 |
from typing import Optional
|
| 5 |
|
| 6 |
class GoogleDocsReader:
|
| 7 |
-
def __init__(self,
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
scopes=['https://www.googleapis.com/auth/documents.readonly']
|
| 11 |
)
|
| 12 |
-
self.
|
| 13 |
|
| 14 |
def read_document(self, document_id: str) -> str:
|
| 15 |
"""Read and extract text from Google Doc"""
|
|
|
|
| 4 |
from typing import Optional
|
| 5 |
|
| 6 |
class GoogleDocsReader:
|
| 7 |
+
def __init__(self, credentials_dict: dict):
|
| 8 |
+
"""
|
| 9 |
+
Initialize with credentials dictionary (decoded from base64)
|
| 10 |
+
"""
|
| 11 |
+
self.credentials = service_account.Credentials.from_service_account_info(
|
| 12 |
+
credentials_dict,
|
| 13 |
scopes=['https://www.googleapis.com/auth/documents.readonly']
|
| 14 |
)
|
| 15 |
+
self.docs_service = build('docs', 'v1', credentials=self.credentials)
|
| 16 |
|
| 17 |
def read_document(self, document_id: str) -> str:
|
| 18 |
"""Read and extract text from Google Doc"""
|