Unable to list files with service account auth for GDriveFilesystem
还没有人认领这个 Issue。
评估
调研方向
从 pydrive2/fs/spec.py 中约第 234 行的服务账号路径开始,将其 GDriveFileSystem 设置与 issue 中可正常工作的 GoogleDrive ListFile().GetList() 示例进行比较。在 shared drive 上复现空列表,并跟踪 API 请求;当 GDriveFileSystem 能够列出服务账号可用的文件时即表示完成。
由索引模型根据 Issue 内容生成。
描述
Hello, I'm using the latest version of the library PyDrive2[fsspec]==1.17.0 and I'm trying to authenticate a service account (the SA email is shared with the drive I wish to test and the keys were generated, I doubt if this order matters).
I followed the steps provided in the docs for the jsonkey file as a string. Its authenticated without errors however I'm unable to list files from the shared drive
- GDrive API is hit
- Listing of files with GDriveFilesystem returns empty (screenshot while debugging)
Digging further, I followed steps mentioned in this comment and was able to list files with the GDrive object however. In fact I noticed the GDrive object being created here and the files get listed (while debugging) when I used
file_list = self.client.ListFile().GetList()
Code snippet:
from oauth2client.service_account import ServiceAccountCredentials
from pydrive2.auth import GoogleAuth
from pydrive2.fs import GDriveFileSystem
from pydrive2.drive import GoogleDrive
def _init_with_service_key(self, service_key_settings: str) -> GDriveFileSystem:
"""Creates a GDriveFileSystem with a service account key."""
# Attempt from issue #21
# scope = ["https://www.googleapis.com/auth/drive"]
# gauth = GoogleAuth()
# gauth.auth_method = 'service'
# gauth.credentials = ServiceAccountCredentials.from_json_keyfile_dict(service_key_settings, scopes=scope)
# drive = GoogleDrive(gauth)
# about = drive.GetAbout()
# file_list = drive.ListFile().GetList()
# gdrive = GDriveFileSystem(
# path="root",
# google_auth=gauth,
# use_service_account=True
# )
gdrive = GDriveFileSystem(
path="root",
use_service_account=True,
client_json=service_key_settings,
skip_instance_cache=True,
use_listings_cache=False
)
return gdrive
Any ideas on how I can proceed? Thanks in advance! :)
- 主要语言
- Python
- 星标
- 668
- 派生
- 75
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
iterative/PyDrive2 的其他 Issue
-
难度 5/5 一周以上 新手友好度 10/100
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 5/5 一周以上 新手友好度 35/100
-
难度 2/5 1-3 小时 新手友好度 30/100
-
难度 3/5 1-2 天 新手友好度 35/100
查看 iterative/PyDrive2 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 1/5 1 小时以内 新手友好度 62/100
-
难度 1/5 1 小时以内 新手友好度 70/100
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
topoteretes/cognee#5773 ·
维护者通常 1 天内回复
-
MiKTeX: a failed build reports no errors because texify --quiet switches the log to file:line: style未关闭
难度 2/5 1-3 小时 新手友好度 74/100
SublimeText/LaTeXTools#1718 ·