Hi
following your comprehensive tutorial, I have been able to set up the link between Anvil and user’s Google Drive, and the oAuth is working great.
Then I tried your example code on a simple form::
from anvil import *
import anvil.google.auth, anvil.google.drive
from anvil.google.drive import app_files
class Form1(Form1Template):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# Any code you write here will run when the form opens.
anvil.google.drive.login()
def text_area_1_show(self, **event_args):
"""This method is called when the text area is shown on the screen"""
folder = anvil.google.drive.get_user_files()
for f in folder.list_files():
self.text_area_1.text += "\n{line}".format(line=f)
This code works and outputs a nice list like this:
<Google Drive File: File 1>
<Google Sheet: Sheet 1>
<Google Sheet: Sheet 2>
<Google Drive File: File 2>
...
If I use f[“title”] as it is in the docs example (instead of simply f), I have an error as soon as Sheet 1 is processed. The errore says KeyError: Spreadsheet contains no worksheet 'title’
at anvil-services/anvil/google/sheets.py line…
So I started to have questions about the object model of folder returned by anvil.google.drive.get_user_files(), and of f returned by folder.list_files(), but I couldn’t find any, neither in the docs, nor in the API Reference.
I assumed Anvil’s API would mimic Google’s Python API and I looked their API for the files list call, I found this (https://developers.google.com/drive/api/v3/reference/files/list) and it’s totally different from yours.
So, where can I find documentation about Anvil APIs to access User’s Google Drive?
Thanks and BR