from google.oauth2.service_account import Credentials
from googleapiclient.discovery import build
import random
import msvcrt
import json
credentials_doc = 'service_account.json'
service_account_info = json.load(open(credentials_doc))
credentials = Credentials.from_service_account_info(service_account_info)
service = build('drive', 'v3', credentials=credentials)
document_id='my_doc_drive_id'
document = service.comments().get(documentId=document_id).execute()
print(document)
error: document = service.comments().get(documentId=document_id).execute() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ raise TypeError("Got an unexpected keyword argument {}".format(name)) TypeError: Got an unexpected keyword argument documentId
how can i get my document ** drivelink:https://docs.google.com/document/d/my_doc_drive_id**
I want to get my drive doc infos and processing incomings
From how can i get my document ** drivelink:https://docs.google.com/document/d/my_doc_drive_id**
and I want to get my drive doc infos and processing incomings
, I believe that your goal is as follows.
document_id='my_doc_drive_id'
.fileId
and commentId
. From your question, I guess that your document_id='my_doc_drive_id'
might be the Google Document ID which is not a comment ID. I guessed that this might be the reason for your current issue.If you want to retrieve the Google Document, it is required to use Google Docs API.
from google.oauth2.service_account import Credentials
from googleapiclient.discovery import build
import json
credentials_doc = 'service_account.json'
service_account_info = json.load(open(credentials_doc))
credentials = Credentials.from_service_account_info(service_account_info)
service = build('docs', 'v1', credentials=credentials)
document_id='my_doc_drive_id' # Please set your Google Document ID.
document = service.documents().get(documentId=document_id).execute()
print(document)
document_id='my_doc_drive_id'
, the object from Google Document is retrieved.If you want to retrieve the file metadata of Google Documents using Drive API, I think that the following script can be used.
from google.oauth2.service_account import Credentials
from googleapiclient.discovery import build
import json
credentials_doc = 'service_account.json'
service_account_info = json.load(open(credentials_doc))
credentials = Credentials.from_service_account_info(service_account_info)
service = build("drive", "v3", credentials=credentials)
document_id='my_doc_drive_id' # Please set your Google Document ID.
document = service.files().get(fileId=document_id, fields="*").execute()
print(document)