A simple way of initializing a pydrive.GoogleDrive object fails when pydrive is replaced by pydrive2

Aberta
#298 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
25/100
Tipo de issue
Bug
Clareza
Precisa de esclarecimento
Status de atividade
Estagnada
Stack de tecnologia
python
Domínio
api, cloud

Direção de pesquisa

A issue não nomeia nenhum arquivo do repositório, teste ou ponto de entrada. Primeiro, reproduza o erro de propagação de credenciais no Google Colab enquanto compara a configuração de pydrive e pydrive2; considera-se concluído quando for identificado se a falha é causada pelo PyDrive2 e for documentada uma inicialização funcional ou uma alternativa simples.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

duplicate question

The following code works when executed in Google Colab. The code is, in fact, copied from one of the official Google Colab tutorials, the one titled External data: Local Files, Drive, Sheets, and Cloud Storage.

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials

auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

However, when pydrive is replaced by pydrive2 in the above listing, and the code is executed in Google Colab, the following error messages result:

---------------------------------------------------------------------------
MessageError                              Traceback (most recent call last)
[<ipython-input-4-3254a9bed9fd>](https://localhost:8080/#) in <cell line: 1>()
----> 1 auth.authenticate_user()
      2 gauth = GoogleAuth()
      3 gauth.credentials = GoogleCredentials.get_application_default()
      4 drive = GoogleDrive(gauth)

2 frames
[/usr/local/lib/python3.10/dist-packages/google/colab/_message.py](https://localhost:8080/#) in read_reply_from_input(message_id, timeout_sec)
    101     ):
    102       if 'error' in reply:
--> 103         raise MessageError(reply['error'])
    104       return reply.get('data', None)
    105 

MessageError: Error: credential propagation was unsuccessful

Why doesn't the code work with pydrive2? Can pydrive2 be made to work with this code? If not, is there a simple alternative?

Linguagem predominante
Python
Estrelas
668
Forks
75
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de iterative/PyDrive2

Todas as issues de iterative/PyDrive2

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.