pydrive.auth.RefreshError: Refresh_token не найден

Я пытаюсь загрузить файл с диска Google с помощью pydrive. код изменен из Автоматизация процесса проверки pydrive

И это дает следующую ошибку.

$ python driveDownload.py a a.xls
Google Drive Token Expired, Refreshing
Traceback (most recent call last):
  File "driveDownload.py", line 26, in <module>
    gauth.Refresh()
  File "build/bdist.linux-x86_64/egg/pydrive/auth.py", line 369, in Refresh
pydrive.auth.RefreshError: No refresh_token found.Please set access_type of OAuth to offline.

Поэтому я следовал инструкциям в соответствии с stackoverflow здесь

Не удалось заставить его работать. Я пропустил что-то основное?

мои настройки .yaml ниже

client_config_backend: settings 
client_config:   
  client_id: ###
  client_secret: ###

save_credentials: True 
save_credentials_backend: file 
save_credentials_file: credentials.json

get_refresh_token: True

oauth_scope:
  - https://www.googleapis.com/auth/drive.file
  - https://www.googleapis.com/auth/drive.install

Я получаю следующую ошибку:

$ python driveDownload.py a a.xls
Google Drive Token Expired, Refreshing
Traceback (most recent call last):
  File "driveDownload.py", line 26, in <module>
    gauth.Refresh()
  File "build/bdist.linux-x86_64/egg/pydrive/auth.py", line 369, in Refresh
pydrive.auth.RefreshError: No refresh_token found.Please set access_type of OAuth to offline.

мой код driveDownload.py:

from pydrive.auth import GoogleAuth
import os
from pydrive.drive import GoogleDrive
import sys

#USAGE: python driveDownload.py googleDriveName localFileName
#authentication via the browser
#note... client_secrets.json is required for this that leads
#to the user authentication
fileName2Download = sys.argv[1]    
#myLocalPath is hard coded and 
myLocalPath = sys.argv[2]


# gauth = GoogleAuth()

gauth = GoogleAuth()
# Try to load saved client credentials
gauth.LoadCredentialsFile("GoogleDriveCredentials.txt")
if gauth.credentials is None:
    # Authenticate if they're not there
    gauth.LocalWebserverAuth()
elif gauth.access_token_expired:
    # Refresh them if expired
    print "Google Drive Token Expired, Refreshing"
    gauth.Refresh()
else:
    # Initialize the saved creds
    gauth.Authorize()
# Save the current credentials to a file
gauth.SaveCredentialsFile("GoogleDriveCredentials.txt")

#accessing the drive
drive = GoogleDrive(gauth)


# Auto-iterate through all files that matches this query
file_list = drive.ListFile().GetList()
for file1 in file_list:
#download the file hello.txt ad myDownload.txt
    print 'title: %s, id: %s , mimeType = %s' % (file1['title'], file1['id'],file1['mimeType'])
    if file1['title'] == fileName2Download:
        print ' file Title identiefied :%s'% (file1['title']) 
#         contentString = file1.GetContentString()
#         print 'contentString : %s' % (contentString)
        myFile = drive.CreateFile({'id': file1['id']})
        if os.path.exists(myLocalPath):
            os.remove(myLocalPath)

        myFile.GetContentFile(myLocalPath,mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
        print '%s downloaded ' %(myLocalPath)
        break

person idom    schedule 03.07.2015    source источник
comment
Refresh_token не найден. Установите для OAuth access_type значение offline. вам нужно исправить вашу аутентификацию. Чтобы ваш код повторно аутентифицировал себя, ему нужен токен обновления. Сообщение об ошибке говорит вам, что вам нужно сделать. извините, я не могу помочь с python   -  person DaImTo    schedule 03.07.2015
comment
@DalmTo Спасибо за ответ. Я не знаю, как это сделать. Любой потенциальный совет должен помочь. Если вы можете помочь с каким-то другим языком, который вы знаете, это будет очень признательно   -  person idom    schedule 03.07.2015
comment
Возможно, этот пример может вам помочь, там объясняется, как добавить параметры к запросу, в данном случае доступ в автономном режиме: developers.google.com/gmail/api/auth/веб-сервер   -  person Gerardo    schedule 07.07.2015