在python中使用服务帐户的Google Drive API未显示共享给我的文件夹

在python中使用服务帐户的Google Drive API未显示共享给我的文件夹,python,google-api-python-client,Python,Google Api Python Client,输出仅显示我拥有的与他人共享的google文档,但不显示我共享给他人的文档。 如何查看共享给我的文件夹结构和文件 我正在使用我的公司Gmail帐户。使用谷歌服务帐户 代码如下 from __future__ import print_function import pickle import os.path from googleapiclient.discovery import build from google_auth_oauthlib.flow import InstalledAppF

输出仅显示我拥有的与他人共享的google文档,但不显示我共享给他人的文档。 如何查看共享给我的文件夹结构和文件

我正在使用我的公司Gmail帐户。使用谷歌服务帐户

代码如下

from __future__ import print_function
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request

# https://developers.google.com/analytics/devguides/config/mgmt/v3/quickstart/service-py
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials

scope = ['https://www.googleapis.com/auth/drive']

credentials = ServiceAccountCredentials.from_json_keyfile_name('creds.json' % path, scope)

# https://developers.google.com/drive/api/v3/quickstart/python
service = build('drive', 'v3', credentials=credentials)

# Call the Drive v3 API
results = service.files().list(
    pageSize=10, fields="nextPageToken, files(id, name)").execute()
items = results.get('files', [])

if not items:
    print('No files found.')
else:
    print('Files:')
    for item in items:
        print(u'{0} ({1})'.format(item['name'], item['id']))

如果服务帐户的电子邮件未与文件夹共享,则当您将服务帐户的电子邮件与文件夹共享时,会得到什么结果?已修复。文件夹未与服务帐户共享谢谢您的答复。我很高兴你的问题解决了。当您的问题得到解决时,您能否将其作为答案发布?这样,它也将对其他有相同问题的用户有用。@Tanaike,这意味着电子邮件(来自服务帐户)应作为查看器(或编辑器——根据需要)添加到Google Drive文件夹中