Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Unable to list files with service account auth for GDriveFilesystem

Đang mở
#307 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
google-cloud, python
Lĩnh vực
api, cloud

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ả

fs

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

  1. GDrive API is hit
    image
  2. Listing of files with GDriveFilesystem returns empty (screenshot while debugging)
    gdrive_issue_proof (1)

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()

gdrive_issue_proof_ls (1)

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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của iterative/PyDrive2

Tất cả issue của iterative/PyDrive2

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.