Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Unable to list files with service account auth for GDriveFilesystem

Aperta
#307 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
google-cloud, python
Ambito
api, cloud

Direzione di ricerca

Inizia con il percorso dell'account di servizio in pydrive2/fs/spec.py intorno alla riga 234 e confronta la configurazione di GDriveFileSystem con l'esempio funzionante di GoogleDrive ListFile().GetList() nell'issue. Riproduci l'elenco vuoto sullo shared drive e traccia la richiesta API; il lavoro è completato quando GDriveFileSystem elenca i file disponibili per l'account di servizio.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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! :)

Lingua principale
Python
Stelle
670
Fork
75
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di iterative/PyDrive2

Tutte le issue di iterative/PyDrive2

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.