Unable to list files with service account auth for GDriveFilesystem
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Bắt đầu với đường dẫn service-account trong pydrive2/fs/spec.py, khoảng dòng 234, và so sánh thiết lập GDriveFileSystem của nó với ví dụ GoogleDrive ListFile().GetList() đang hoạt động trong issue. Tái hiện danh sách trống trên shared drive và lần theo yêu cầu API; hoàn tất khi GDriveFileSystem liệt kê các tệp mà service account có thể truy cập.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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! :)
- Ngôn ngữ chính
- Python
- Star
- 670
- Fork
- 75
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của iterative/PyDrive2
-
Is this abandon ware? Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 30/100
-
Update cryptography to 44.0.0 Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Tất cả issue của iterative/PyDrive2
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stephrobert/dsoxlab#238 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
sublimehq/package_control#1780 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
nwg-piotr/nwg-displays#145 ·