### Install PyDrive2 from GitHub Source: https://docs.iterative.ai/PyDrive2 Install the development version of PyDrive2 directly from its GitHub repository. ```bash pip install git+https://github.com/iterative/PyDrive2.git#egg=PyDrive2 ``` -------------------------------- ### Install PyDrive2 with pip Source: https://docs.iterative.ai/PyDrive2/_sources/index.rst.txt Install the stable version of PyDrive2 using pip. ```bash pip install PyDrive2 ``` -------------------------------- ### Install PyDrive2 from GitHub Source: https://docs.iterative.ai/PyDrive2/_sources/index.rst.txt Install the development version of PyDrive2 directly from its GitHub repository. ```bash pip install git+https://github.com/iterative/PyDrive2.git#egg=PyDrive2 ``` -------------------------------- ### Install PyDrive2 with pip Source: https://docs.iterative.ai/PyDrive2 Install the latest stable version of PyDrive2 using pip. ```bash pip install PyDrive2 ``` -------------------------------- ### Install PyDrive2 with fsspec support Source: https://docs.iterative.ai/PyDrive2/_sources/fsspec.rst.txt Install the PyDrive2 library with the necessary extras for fsspec integration. ```sh pip install 'pydrive2[fsspec]' ``` -------------------------------- ### Get Files by Complex Queries Source: https://docs.iterative.ai/PyDrive2/filemanagement Fetches a list of files matching a specific title and MIME type. This is useful when filenames are not unique. Requires a GoogleDrive instance and a defined filename and mimetype. ```python from pydrive2.drive import GoogleDrive # Create GoogleDrive instance with authenticated GoogleAuth instance. drive = GoogleDrive(gauth) filename = 'file_test' # Query query = {'q': f"title = '{filename}' and mimeType='{mimetype}'"} # Get list of files that match against the query files = drive.ListFile(query).GetList() ``` -------------------------------- ### Insert File Permission Source: https://docs.iterative.ai/PyDrive2/_sources/filemanagement.rst.txt Inserts a permission for a file, making it accessible to others. This example makes a file readable by anyone with the link. ```python file1 = drive.CreateFile() file1.Upload() # Insert the permission. permission = file1.InsertPermission({ 'type': 'anyone', 'value': 'anyone', 'role': 'reader'}) print(file1['alternateLink']) # Display the sharable link. ``` -------------------------------- ### Paginate Through File Lists Source: https://docs.iterative.ai/PyDrive2/_sources/filelist.rst.txt Efficiently paginate through large lists of Google Drive files. This example specifies the number of results to retrieve per request (`maxResults`) and iterates through each batch. It's useful for handling many files without overwhelming memory. ```python # Paginate file lists by specifying number of max results for file_list in drive.ListFile({'q': 'trashed=true', 'maxResults': 10}): print('Received %s files from Files.list()' % len(file_list)) # <= 10 for file1 in file_list: print('title: %s, id: %s' % (file1['title'], file1['id'])) ``` -------------------------------- ### Get All Files Matching a Query Source: https://docs.iterative.ai/PyDrive2/_sources/filelist.rst.txt Retrieve all files from Google Drive that match a specified query. This snippet iterates through the files and prints their titles and IDs. Ensure you have authenticated with Google Drive using `gauth`. ```python from pydrive2.drive import GoogleDrive drive = GoogleDrive(gauth) # Create GoogleDrive instance with authenticated GoogleAuth instance # Auto-iterate through all files in the root folder. file_list = drive.ListFile({'q': "'root' in parents and trashed=false"}).GetList() for file1 in file_list: print('title: %s, id: %s' % (file1['title'], file1['id'])) ``` -------------------------------- ### Get Content String with Encoding Source: https://docs.iterative.ai/PyDrive2/filemanagement Retrieves file content as a string, allowing specification of the character encoding. Useful for files not encoded in UTF-8. ```python content_string = file4.GetContentString(encoding='ISO-8859-1') ``` -------------------------------- ### Get All Files Matching a Query Source: https://docs.iterative.ai/PyDrive2/filelist Use this snippet to retrieve all files from Google Drive that match a specified query. It iterates through the files and prints their titles and IDs. Ensure you have authenticated with GoogleAuth. ```python from pydrive2.drive import GoogleDrive drive = GoogleDrive(gauth) # Create GoogleDrive instance with authenticated GoogleAuth instance # Auto-iterate through all files in the root folder. file_list = drive.ListFile({'q': "'root' in parents and trashed=false"}).GetList() for file1 in file_list: print('title: %s, id: %s' % (file1['title'], file1['id'])) ``` -------------------------------- ### Initialize GDriveFileSystem with service account and JSON keyfile Source: https://docs.iterative.ai/PyDrive2/_sources/fsspec.rst.txt Initialize the GDriveFileSystem for service account authentication using a JSON keyfile path. Ensure the service account has access to the specified drive or directory. ```python from pydrive2.fs import GDriveFileSystem fs = GDriveFileSystem( # replace with ID of a drive or directory and give service account access to it "root", use_service_account=True, client_json_file_path="/path/to/keyfile.json", ) ``` -------------------------------- ### Initialize GDriveFileSystem with service account and JSON string Source: https://docs.iterative.ai/PyDrive2/_sources/fsspec.rst.txt Initialize the GDriveFileSystem for service account authentication using a JSON string containing credentials. The service account must have access to the target drive or directory. ```python from pydrive2.fs import GDriveFileSystem fs = GDriveFileSystem( # replace with ID of a drive or directory and give service account access to it "root", use_service_account=True, client_json=json_string, ) ``` -------------------------------- ### Initialize GDriveFileSystem using a client JSON string Source: https://docs.iterative.ai/PyDrive2/_sources/fsspec.rst.txt Initialize the GDriveFileSystem using a JSON string containing client credentials, bypassing interactive authentication. ```python from pydrive2.fs import GDriveFileSystem fs = GDriveFileSystem( "root", client_id="my_client_id", client_secret="my_client_secret", client_json=json_string, ) ``` -------------------------------- ### Initialize GDriveFileSystem with local webserver Source: https://docs.iterative.ai/PyDrive2/_sources/fsspec.rst.txt Initialize the GDriveFileSystem using client ID and secret for local webserver authentication. Credentials are cached by default. ```python from pydrive2.fs import GDriveFileSystem fs = GDriveFileSystem( "root", client_id="my_client_id", client_secret="my_client_secret", ) ``` -------------------------------- ### Initialize GDriveFileSystem using a client JSON file Source: https://docs.iterative.ai/PyDrive2/_sources/fsspec.rst.txt Initialize the GDriveFileSystem by providing the path to a client JSON keyfile, which avoids interactive authentication. ```python from pydrive2.fs import GDriveFileSystem fs = GDriveFileSystem( "root", client_id="my_client_id", client_secret="my_client_secret", client_json_file_path="/path/to/keyfile.json", ) ``` -------------------------------- ### GoogleAuth.GetFlow Source: https://docs.iterative.ai/PyDrive2/pydrive2 Gets the OAuth2 flow object. ```APIDOC ## GoogleAuth.GetFlow ### Description Gets the OAuth2 flow object. ### Method GoogleAuth.GetFlow() ``` -------------------------------- ### Initialize GDriveFileSystem with profile for multiple users Source: https://docs.iterative.ai/PyDrive2/_sources/fsspec.rst.txt Initialize the GDriveFileSystem with a profile name to manage cached credentials for different users, preventing accidental credential mix-ups. ```python from pydrive2.fs import GDriveFileSystem fs = GDriveFileSystem( "root", client_id="my_client_id", client_secret="my_client_secret", profile="myprofile", ) ``` -------------------------------- ### Get File ID by Title Source: https://docs.iterative.ai/PyDrive2/_sources/quickstart.rst.txt A function to find and return the ID of a file within a specific parent directory by its title. It iterates through files in the directory and compares titles. ```python def get_id_of_title(title,parent_directory_id): foldered_list=drive.ListFile({'q': "'"+parent_directory_id+"' in parents and trashed=false"}).GetList() for file in foldered_list: if(file['title']==title): return file['id'] return None ``` -------------------------------- ### Delete, Trash, and Un-Trash Files Source: https://docs.iterative.ai/PyDrive2/filemanagement Demonstrates how to move files to the trash, restore them, or delete them permanently using PyDrive2. ```python # Create GoogleDriveFile instance and upload it. file1 = drive.CreateFile() file1.Upload() file1.Trash() # Move file to trash. file1.UnTrash() # Move file out of trash. file1.Delete() # Permanently delete the file. ``` -------------------------------- ### GoogleAuth.LoadClientConfigFile Source: https://docs.iterative.ai/PyDrive2/pydrive2 Loads the client configuration from a file. ```APIDOC ## GoogleAuth.LoadClientConfigFile ### Description Loads the client configuration from a file. ### Method GoogleAuth.LoadClientConfigFile() ``` -------------------------------- ### GoogleAuth.LoadClientConfigSettings Source: https://docs.iterative.ai/PyDrive2/pydrive2 Loads client configuration settings. ```APIDOC ## GoogleAuth.LoadClientConfigSettings ### Description Loads client configuration settings. ### Method GoogleAuth.LoadClientConfigSettings() ``` -------------------------------- ### Create and Update a File Source: https://docs.iterative.ai/PyDrive2/_sources/quickstart.rst.txt Demonstrates creating a new file in Google Drive with a specified title and content, and then uploading it. This uses the CreateFile and Upload methods. ```python from pydrive2.drive import GoogleDrive drive = GoogleDrive(gauth) file1 = drive.CreateFile({'title': 'Hello.txt'}) # Create GoogleDriveFile instance with title 'Hello.txt'. file1.SetContentString('Hello World!') # Set content of the file from given string. file1.Upload() ``` -------------------------------- ### Command Line Authentication Source: https://docs.iterative.ai/PyDrive2/_sources/oauth.rst.txt Use CommandLineAuth() to obtain an authentication token by pasting a link into the command line. This is an alternative to LocalWebserverAuth(). ```python # gauth.CommandLineAuth() ``` -------------------------------- ### Upload and Update File Content Source: https://docs.iterative.ai/PyDrive2/filemanagement Demonstrates uploading a new file with content and then updating its content. Supports setting content via string or from a file. ```python file4 = drive.CreateFile({'title':'appdata.json', 'mimeType':'application/json'}) file4.SetContentString('{"firstname": "John", "lastname": "Smith"}') file4.Upload() # Upload file. file4.SetContentString('{"firstname": "Claudio", "lastname": "Afshar"}') file4.Upload() # Update content of the file. file5 = drive.CreateFile() # Read file and set it as a content of this instance. file5.SetContentFile('cat.png') file5.Upload() # Upload the file. print('title: %s, mimeType: %s' % (file5['title'], file5['mimeType'])) # title: cat.png, mimeType: image/png ``` -------------------------------- ### Walk through the GDriveFileSystem Source: https://docs.iterative.ai/PyDrive2/fsspec Iterate through directories and files within a specified root directory using the GDriveFileSystem. This demonstrates basic file traversal. ```python # replace `root` with ID of a drive or directory and give service account access to it for root, dnames, fnames in fs.walk("root"): for dname in dnames: print(f"dir: {root}/{dname}") for fname in fnames: print(f"file: {root}/{fname}") ``` -------------------------------- ### GoogleDrive.ListFile Source: https://docs.iterative.ai/PyDrive2/pydrive2 Creates an instance of GoogleDriveFileList, initialized with the provided parameters for the Files.List() method. This method does not fetch files directly. ```APIDOC ## GoogleDrive.ListFile ### Description Create an instance of GoogleDriveFileList with auth of this instance. This method will not fetch from Files.List(). ### Method ListFile ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **param** (dict) - parameter to be sent to Files.List(). ### Response #### Success Response - pydrive2.files.GoogleDriveFileList – initialized with auth of this instance. ### Request Example None ### Response Example None ``` -------------------------------- ### GoogleAuth.LoadServiceConfigSettings Source: https://docs.iterative.ai/PyDrive2/pydrive2 Loads service configuration settings. ```APIDOC ## GoogleAuth.LoadServiceConfigSettings ### Description Loads service configuration settings. ### Method GoogleAuth.LoadServiceConfigSettings() ``` -------------------------------- ### GoogleAuth.LoadClientConfig Source: https://docs.iterative.ai/PyDrive2/pydrive2 Loads the client configuration. ```APIDOC ## GoogleAuth.LoadClientConfig ### Description Loads the client configuration. ### Method GoogleAuth.LoadClientConfig() ``` -------------------------------- ### Fetch File Permissions Source: https://docs.iterative.ai/PyDrive2/filemanagement Retrieves file metadata, specifically the 'permissions' field, and prints the permissions array. Ensure the file object is initialized. ```python file1.FetchMetadata(fields='permissions') print(file1['permissions']) ``` -------------------------------- ### GoogleAuth.CommandLineAuth Source: https://docs.iterative.ai/PyDrive2/pydrive2 Performs authentication using command-line arguments. ```APIDOC ## GoogleAuth.CommandLineAuth ### Description Performs authentication using command-line arguments. ### Method GoogleAuth.CommandLineAuth() ``` -------------------------------- ### GoogleDrive.CreateFile Source: https://docs.iterative.ai/PyDrive2/pydrive2 Creates an instance of GoogleDriveFile, initializing it with the provided metadata. This method does not upload the file to Google Drive. ```APIDOC ## GoogleDrive.CreateFile ### Description Create an instance of GoogleDriveFile with auth of this instance. This method would not upload a file to GoogleDrive. ### Method CreateFile ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **metadata** (dict) - file resource to initialize GoogleDriveFile with. ### Response #### Success Response - pydrive2.files.GoogleDriveFile – initialized with auth of this instance. ### Request Example None ### Response Example None ``` -------------------------------- ### LoadAuth Source: https://docs.iterative.ai/PyDrive2/pydrive2 Loads authentication settings. ```APIDOC ## LoadAuth ### Description Loads authentication settings. ### Method LoadAuth() ``` -------------------------------- ### GoogleAuth.Auth Source: https://docs.iterative.ai/PyDrive2/pydrive2 Initiates the Google authentication process. ```APIDOC ## GoogleAuth.Auth ### Description Initiates the Google authentication process. ### Method GoogleAuth.Auth() ``` -------------------------------- ### GoogleDrive.CreateFile Source: https://docs.iterative.ai/PyDrive2/pydrive2 Creates a new file in Google Drive. ```APIDOC ## GoogleDrive.CreateFile ### Description Creates a new file in Google Drive. ### Method GoogleDrive.CreateFile() ``` -------------------------------- ### GoogleDrive.GetAbout Source: https://docs.iterative.ai/PyDrive2/pydrive2 Retrieves information about the authenticated Google Drive instance, including user details, usage, and quota. ```APIDOC ## GoogleDrive.GetAbout ### Description Return information about the Google Drive of the auth instance. ### Method GetAbout ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response A dictionary of Google Drive information like user, usage, quota etc. ### Request Example None ### Response Example None ``` -------------------------------- ### LoadSettingsFile Source: https://docs.iterative.ai/PyDrive2/pydrive2 Loads settings from a YAML file. This function is used to configure the pydrive2 library with user-defined settings. ```APIDOC ## LoadSettingsFile ### Description Loads settings from a YAML file. ### Parameters #### Path Parameters - **filename** (str) - Optional - path for settings file. ‘settings.yaml’ by default. ### Raises - SettingsError ``` -------------------------------- ### GoogleDrive.GetAbout Source: https://docs.iterative.ai/PyDrive2/pydrive2 Retrieves information about the Google Drive account. ```APIDOC ## GoogleDrive.GetAbout ### Description Retrieves information about the Google Drive account. ### Method GoogleDrive.GetAbout() ``` -------------------------------- ### GDriveFileSystem Source: https://docs.iterative.ai/PyDrive2/pydrive2 Provides access to Google Drive as an fsspec filesystem, allowing for file system-like operations on Google Drive. ```APIDOC ## GDriveFileSystem ### Description Access to gdrive as an fsspec filesystem. ### Class GDriveFileSystem ``` -------------------------------- ### Customizing Authentication with settings.yaml Source: https://docs.iterative.ai/PyDrive2/_sources/oauth.rst.txt Define custom authentication flows, such as silent authentication on remote machines, by creating a settings.yaml file. This allows overriding default settings for client configuration and OAuth scopes. ```python client_config_backend: {{str}} client_config_file: {{str}} client_config: client_id: {{str}} client_secret: {{str}} auth_uri: {{str}} token_uri: {{str}} redirect_uri: {{str}} revoke_uri: {{str}} service_config: client_user_email: {{str}} client_json_file_path: {{str}} client_json_dict: {{dict}} client_json: {{str}} save_credentials: {{bool}} save_credentials_backend: {{str}} save_credentials_file: {{str}} save_credentials_dict: {{dict}} save_credentials_key: {{str}} get_refresh_token: {{bool}} oauth_scope: {{list of str}} ``` -------------------------------- ### pydrive2.fs.GDriveFileSystem Class Source: https://docs.iterative.ai/PyDrive2/_sources/pydrive2.rst.txt Documents the GDriveFileSystem class within the pydrive2.fs module, including its inheritance. ```APIDOC ## pydrive2.fs.GDriveFileSystem Class ### Description This section documents the GDriveFileSystem class, which inherits from a base class. ### Inheritance (Details of inheritance would be listed here if available in the source) ``` -------------------------------- ### GoogleAuth.LoadCredentialsFile Source: https://docs.iterative.ai/PyDrive2/pydrive2 Loads user credentials from a file. ```APIDOC ## GoogleAuth.LoadCredentialsFile ### Description Loads user credentials from a file. ### Method GoogleAuth.LoadCredentialsFile() ``` -------------------------------- ### GoogleDriveFile.FetchContent Source: https://docs.iterative.ai/PyDrive2/pydrive2 Fetches the content of a Google Drive file. ```APIDOC ## GoogleDriveFile.FetchContent ### Description Fetches the content of a Google Drive file. ### Method GoogleDriveFile.FetchContent() ``` -------------------------------- ### GoogleDrive.ListFile Source: https://docs.iterative.ai/PyDrive2/pydrive2 Lists files in Google Drive. ```APIDOC ## GoogleDrive.ListFile ### Description Lists files in Google Drive. ### Method GoogleDrive.ListFile() ``` -------------------------------- ### Create Folder in Google Drive Source: https://docs.iterative.ai/PyDrive2/_sources/quickstart.rst.txt Creates a new folder within the specified parent directory. Ensure the necessary directory structure exists before creating. ```python if inp==':': print("Enter Name of Folder You Want to Create") inp=input() newfolder=create_folder(parent_id,inp) if not os.path.exists(HOME_DIRECTORY+ROOT_FOLDER_NAME+os.path.sep+USERNAME): os.makedirs(HOME_DIRECTORY+ROOT_FOLDER_NAME+os.path.sep+USERNAME) return newfolder['id'] ``` -------------------------------- ### Walk through Google Drive directory structure Source: https://docs.iterative.ai/PyDrive2/_sources/fsspec.rst.txt Iterate through directories and files within a specified Google Drive path using the GDriveFileSystem's walk method. ```python # replace `root` with ID of a drive or directory and give service account access to it for root, dnames, fnames in fs.walk("root"): for dname in dnames: print(f"dir: {root}/{dname}") for fname in fnames: print(f"file: {root}/{fname}") ``` -------------------------------- ### pydrive2.settings Module Source: https://docs.iterative.ai/PyDrive2/_sources/pydrive2.rst.txt Provides access to the members, undocumented members, and inheritance information for the pydrive2.settings module. ```APIDOC ## pydrive2.settings Module ### Description This section documents the pydrive2.settings module, listing its members, undocumented members, and inheritance. ### Members (Details of members would be listed here if available in the source) ``` -------------------------------- ### List File Permissions Source: https://docs.iterative.ai/PyDrive2/_sources/filemanagement.rst.txt Fetches the permissions associated with a file using the GetPermissions() function. This allows you to check how a file is shared. ```python # Create a new file ``` -------------------------------- ### GoogleAuth.Authorize Source: https://docs.iterative.ai/PyDrive2/pydrive2 Authorizes the application with Google. ```APIDOC ## GoogleAuth.Authorize ### Description Authorizes the application with Google. ### Method GoogleAuth.Authorize() ``` -------------------------------- ### Download Abusive Files Source: https://docs.iterative.ai/PyDrive2/_sources/filemanagement.rst.txt To download files identified as abusive (malware, spam), you must explicitly acknowledge the risks by setting acknowledge_abuse=True in GetContentFile. This parameter is only effective for the file owner. ```python # Example usage (assuming 'file_obj' is a GoogleDriveFile instance): # file_obj.GetContentFile('malware.exe', acknowledge_abuse=True) ``` -------------------------------- ### ApiResourceList.GetList Source: https://docs.iterative.ai/PyDrive2/pydrive2 Retrieves a list of API resources. ```APIDOC ## ApiResourceList.GetList ### Description Retrieves a list of API resources. ### Method ApiResourceList.GetList() ``` -------------------------------- ### Fetch File Metadata and Permissions Source: https://docs.iterative.ai/PyDrive2/filemanagement/index.html Retrieves specific metadata fields, including permissions, for a given file. The permissions array can then be accessed directly from the file object. ```python file1 = drive.CreateFile({'id': ''}) file1.FetchMetadata(fields='permissions') print(file1['permissions']) ``` -------------------------------- ### Insert File Permissions Source: https://docs.iterative.ai/PyDrive2/filemanagement Makes a file readable by anyone with the link by inserting a new permission. This operation automatically calls GetPermissions() afterwards. ```python file1 = drive.CreateFile() file1.Upload() # Insert the permission. permission = file1.InsertPermission({ 'type': 'anyone', 'value': 'anyone', 'role': 'reader'}) print(file1['alternateLink']) # Display the sharable link. ``` -------------------------------- ### Fetch File Metadata with Specific Fields Source: https://docs.iterative.ai/PyDrive2/_sources/filemanagement.rst.txt Fetches specific metadata fields for a file, such as 'permissions'. This is an advanced method for selectively retrieving file information. ```python # Fetch Metadata, including the permissions field. file1.FetchMetadata(fields='permissions') # The permissions array is now available for further use. print(file1['permissions']) ``` -------------------------------- ### Download File Content as String Source: https://docs.iterative.ai/PyDrive2/filemanagement Retrieves the content of a Google Drive file as a string. Useful for text-based files. Requires initializing the file object with its ID. ```python # Initialize GoogleDriveFile instance with file id. file7 = drive.CreateFile({'id': file4['id']}) content = file7.GetContentString() # content: '{"firstname": "Claudio", "lastname": "Afshar"}' file7.SetContentString(content.replace('lastname', 'familyname')) file7.Upload() ``` -------------------------------- ### Upload and Update File Content from String Source: https://docs.iterative.ai/PyDrive2/filemanagement/index.html Sets and uploads file content using a string. This method can be used for both initial uploads and subsequent updates to the file's content. ```python file4 = drive.CreateFile({'title':'appdata.json', 'mimeType':'application/json'}) file4.SetContentString('{"firstname": "John", "lastname": "Smith"}') file4.Upload() # Upload file. file4.SetContentString('{"firstname": "Claudio", "lastname": "Afshar"}') file4.Upload() # Update content of the file. ``` -------------------------------- ### Browse and Select Folders in Google Drive Source: https://docs.iterative.ai/PyDrive2/quickstart This Python function recursively browses folders in Google Drive, prints their titles, and allows the user to select an existing folder, create a new one, or use the current folder. It requires the `os` module and assumes `create_folder`, `HOME_DIRECTORY`, `ROOT_FOLDER_NAME`, and `USERNAME` are defined elsewhere. ```python browsed=[] def folder_browser(folder_list,parent_id): for element in folder_list: if type(element) is dict: print (element['title']) else: print (element) print("Enter Name of Folder You Want to Use\nEnter '/' to use current folder\nEnter ':' to create New Folder and use that" ) inp=input() if inp=='/': return parent_id elif inp==':': print("Enter Name of Folder You Want to Create") inp=input() newfolder=create_folder(parent_id,inp) if not os.path.exists(HOME_DIRECTORY+ROOT_FOLDER_NAME+os.path.sep+USERNAME): os.makedirs(HOME_DIRECTORY+ROOT_FOLDER_NAME+os.path.sep+USERNAME) return newfolder['id'] else: folder_selected=inp for element in folder_list: if type(element) is dict: if element["title"]==folder_selected: struc=element["list"] browsed.append(folder_selected) print("Inside "+folder_selected) return folder_browser(struc,element['id']) ``` -------------------------------- ### Browse Folder in Google Drive Source: https://docs.iterative.ai/PyDrive2/_sources/quickstart.rst.txt Navigates into a selected folder, displaying its contents. This function recursively browses through the directory structure. ```python else: folder_selected=inp for element in folder_list: if type(element) is dict: if element["title"]==folder_selected: struc=element["list"] browsed.append(folder_selected) print("Inside "+folder_selected) return folder_browser(struc,element['id']) ``` -------------------------------- ### List File Revisions Source: https://docs.iterative.ai/PyDrive2/filemanagement Fetches and prints the revisions for a given file. Note that not all file objects have revisions, and calling this on such an object will raise an exception. ```python # Create a new file file1 = drive.CreateFile() # Fetch revisions. revisions = file1.GetRevisions() print(revisions) ``` -------------------------------- ### Fetch File Permissions Source: https://docs.iterative.ai/PyDrive2/_sources/filemanagement.rst.txt Retrieves the permissions associated with a Google Drive file. Permissions can be accessed directly from the file object or via the GetPermissions() method. ```python file1 = drive.CreateFile() # Fetch permissions. permissions = file1.GetPermissions() print(permissions) # The permissions are also available as file1['permissions']: print(file1['permissions']) ``` -------------------------------- ### GoogleDriveFile.FetchMetadata Source: https://docs.iterative.ai/PyDrive2/pydrive2 Fetches the metadata of a Google Drive file. ```APIDOC ## GoogleDriveFile.FetchMetadata ### Description Fetches the metadata of a Google Drive file. ### Method GoogleDriveFile.FetchMetadata() ``` -------------------------------- ### GoogleAuth.LoadCredentials Source: https://docs.iterative.ai/PyDrive2/pydrive2 Loads user credentials. ```APIDOC ## GoogleAuth.LoadCredentials ### Description Loads user credentials. ### Method GoogleAuth.LoadCredentials() ``` -------------------------------- ### GoogleDriveFile.FetchMetadata Source: https://docs.iterative.ai/PyDrive2/pydrive2 Downloads the metadata for the Google Drive file using its ID. Users can specify which fields to fetch or choose to fetch all available fields. ```APIDOC ## GoogleDriveFile.FetchMetadata ### Description Download file’s metadata from id using Files.get(). ### Method FetchMetadata ### Parameters #### Path Parameters None #### Query Parameters - **fields** (str) - Optional - The fields to include, as one string, each entry separated by commas, e.g. ‘fields,labels’. - **fetch_all** (bool) - Optional - Whether to fetch all fields. ### Raises - ApiRequestError - FileNotUploadedError ``` -------------------------------- ### GoogleDriveFile.FetchContent Source: https://docs.iterative.ai/PyDrive2/pydrive2 Downloads the content of the Google Drive file from its download URL. This method handles potential API request errors, and issues related to files that are not yet uploaded or downloadable. ```APIDOC ## GoogleDriveFile.FetchContent ### Description Download file’s content from download_url. ### Method FetchContent ### Parameters #### Path Parameters None #### Query Parameters - **mimetype** (str) - Optional - The MIME type of the file. - **remove_bom** (bool) - Optional - Whether to remove the byte order marking. ### Raises - ApiRequestError - FileNotUploadedError - FileNotDownloadableError ``` -------------------------------- ### LoadMetadata Source: https://docs.iterative.ai/PyDrive2/pydrive2 Loads metadata for a file. ```APIDOC ## LoadMetadata ### Description Loads metadata for a file. ### Method LoadMetadata() ``` -------------------------------- ### GoogleDriveFile.Copy Source: https://docs.iterative.ai/PyDrive2/pydrive2 Copies a Google Drive file. ```APIDOC ## GoogleDriveFile.Copy ### Description Copies a Google Drive file. ### Method GoogleDriveFile.Copy() ``` -------------------------------- ### List File Permissions Source: https://docs.iterative.ai/PyDrive2/filemanagement Retrieves the permissions associated with a GoogleDriveFile. Permissions can be accessed directly via the 'permissions' key or by calling GetPermissions(). ```python # Create a new file file1 = drive.CreateFile() # Fetch permissions. permissions = file1.GetPermissions() print(permissions) # The permissions are also available as file1['permissions']: print(file1['permissions']) ``` -------------------------------- ### pydrive2.drive Module Source: https://docs.iterative.ai/PyDrive2/_sources/pydrive2.rst.txt Provides access to the members, undocumented members, and inheritance information for the pydrive2.drive module. ```APIDOC ## pydrive2.drive Module ### Description This section documents the pydrive2.drive module, listing its members, undocumented members, and inheritance. ### Members (Details of members would be listed here if available in the source) ``` -------------------------------- ### pydrive2.files Module Source: https://docs.iterative.ai/PyDrive2/_sources/pydrive2.rst.txt Provides access to the members, undocumented members, and inheritance information for the pydrive2.files module. ```APIDOC ## pydrive2.files Module ### Description This section documents the pydrive2.files module, listing its members, undocumented members, and inheritance. ### Members (Details of members would be listed here if available in the source) ``` -------------------------------- ### Paginate and Iterate Through Files Source: https://docs.iterative.ai/PyDrive2/filelist This snippet demonstrates how to paginate through file lists by specifying the 'maxResults' parameter. It retrieves files in batches and prints the number of files received in each batch, along with their titles and IDs. This is useful for handling large numbers of files efficiently. ```python # Paginate file lists by specifying number of max results for file_list in drive.ListFile({'q': 'trashed=true', 'maxResults': 10}): print('Received %s files from Files.list()' % len(file_list)) # <= 10 for file1 in file_list: print('title: %s, id: %s' % (file1['title'], file1['id'])) ``` -------------------------------- ### Download File Content to Local File Source: https://docs.iterative.ai/PyDrive2/filemanagement Downloads the content of a Google Drive file and saves it to a specified local filename. Requires initializing the file object with its ID. ```python # Initialize GoogleDriveFile instance with file id. file6 = drive.CreateFile({'id': file5['id']}) file6.GetContentFile('catlove.png') # Download file as 'catlove.png'. ``` -------------------------------- ### GoogleDriveFile.Upload Source: https://docs.iterative.ai/PyDrive2/pydrive2 Uploads changes to a Google Drive file. ```APIDOC ## GoogleDriveFile.Upload ### Description Uploads changes to a Google Drive file. ### Method GoogleDriveFile.Upload() ``` -------------------------------- ### pydrive2.auth Module Source: https://docs.iterative.ai/PyDrive2/_sources/pydrive2.rst.txt Provides access to the members, undocumented members, and inheritance information for the pydrive2.auth module. ```APIDOC ## pydrive2.auth Module ### Description This section documents the pydrive2.auth module, listing its members, undocumented members, and inheritance. ### Members (Details of members would be listed here if available in the source) ``` -------------------------------- ### GoogleDriveFile.GetPermissions Source: https://docs.iterative.ai/PyDrive2/pydrive2 Retrieves the permissions for a Google Drive file. ```APIDOC ## GoogleDriveFile.GetPermissions ### Description Retrieves the permissions for a Google Drive file. ### Method GoogleDriveFile.GetPermissions() ``` -------------------------------- ### GoogleDriveFile.GetContentFile Source: https://docs.iterative.ai/PyDrive2/pydrive2 Retrieves the content of a Google Drive file as a file. ```APIDOC ## GoogleDriveFile.GetContentFile ### Description Retrieves the content of a Google Drive file as a file. ### Method GoogleDriveFile.GetContentFile() ``` -------------------------------- ### ApiResourceList.GetList Source: https://docs.iterative.ai/PyDrive2/pydrive2 Retrieves a list of API resources. If maxResults is not specified, it iterates through all available resources. ```APIDOC ## ApiResourceList.GetList ### Description Get list of API resources. If ‘maxResults’ is not specified, it will automatically iterate through every resources available. Otherwise, it will make API call once and update ‘pageToken’. ### Method GetList() ### Parameters None ### Response #### Success Response - **list** – list of API resources. ### Response Example ```json { "example": "list of api resources" } ``` ``` -------------------------------- ### GoogleDriveFile.Trash Source: https://docs.iterative.ai/PyDrive2/pydrive2 Moves a Google Drive file to the trash. ```APIDOC ## GoogleDriveFile.Trash ### Description Moves a Google Drive file to the trash. ### Method GoogleDriveFile.Trash() ``` -------------------------------- ### Upload a New File Source: https://docs.iterative.ai/PyDrive2/filemanagement Uploads a new text file to Google Drive. Ensure you have an authenticated GoogleAuth object initialized. ```python from pydrive2.drive import GoogleDrive # Create GoogleDrive instance with authenticated GoogleAuth instance. drive = GoogleDrive(gauth) # Create GoogleDriveFile instance with title 'Hello.txt'. file1 = drive.CreateFile({'title': 'Hello.txt'}) file1.Upload() # Upload the file. print('title: %s, id: %s' % (file1['title'], file1['id'])) # title: Hello.txt, id: {{FILE_ID}} ``` -------------------------------- ### IoBuffer.write Source: https://docs.iterative.ai/PyDrive2/pydrive2 Writes data to an IOBuffer. ```APIDOC ## IoBuffer.write ### Description Writes data to an IOBuffer. ### Method IoBuffer.write() ``` -------------------------------- ### Custom Authentication Flow with PyDrive2 Source: https://docs.iterative.ai/PyDrive2/oauth Use this snippet to implement a custom authentication flow. It involves obtaining an authorization URL, having the user grant access, and then authorizing PyDrive2 with the provided code. ```python from pydrive2.auth import GoogleAuth gauth = GoogleAuth() auth_url = gauth.GetAuthUrl() # Create authentication url user needs to visit code = AskUserToVisitLinkAndGiveCode(auth_url) # Your customized authentication flow gauth.Auth(code) # Authorize and build service from the code ``` -------------------------------- ### Download File Metadata by ID Source: https://docs.iterative.ai/PyDrive2/filemanagement Retrieves file metadata, such as title and mimeType, using the file's ID. Initialize GoogleDriveFile with the ID to access its properties. ```python # Create GoogleDriveFile instance with file id of file1. file2 = drive.CreateFile({'id': file1['id']}) print('title: %s, mimeType: %s' % (file2['title'], file2['mimeType'])) # title: HelloWorld.txt, mimeType: text/plain ``` -------------------------------- ### List Files in Root Directory Source: https://docs.iterative.ai/PyDrive2/_sources/quickstart.rst.txt Retrieves and prints the titles and IDs of all files in the root folder of Google Drive that are not trashed. It uses the ListFile and GetList methods with a query. ```python # Auto-iterate through all files that matches this query file_list = drive.ListFile({'q': "'root' in parents and trashed=false"}).GetList() for file1 in file_list: print('title: %s, id: %s' % (file1['title'], file1['id'])) ``` -------------------------------- ### Simple OAuth2.0 Authentication Source: https://docs.iterative.ai/PyDrive2/_sources/oauth.rst.txt Use LocalWebserverAuth() for automatic authentication via a local webserver. This method is suitable for interactive environments. ```python from pydrive2.auth import GoogleAuth gauth = GoogleAuth() # Create local webserver and auto handles authentication. gauth.LocalWebserverAuth() ``` -------------------------------- ### GoogleDriveFile.GetContentIOBuffer Source: https://docs.iterative.ai/PyDrive2/pydrive2 Retrieves the content of a Google Drive file as an IOBuffer. ```APIDOC ## GoogleDriveFile.GetContentIOBuffer ### Description Retrieves the content of a Google Drive file as an IOBuffer. ### Method GoogleDriveFile.GetContentIOBuffer() ``` -------------------------------- ### PyDrive2 OAuth Authentication Source: https://docs.iterative.ai/PyDrive2/oauth Simplifies OAuth2.0 authentication using PyDrive2's GoogleAuth class. Use LocalWebserverAuth() for automatic handling via a local webserver, or CommandLineAuth() for manual token input. ```python from pydrive2.auth import GoogleAuth gauth = GoogleAuth() # Create local webserver and auto handles authentication. gauth.LocalWebserverAuth() # Or use the CommandLineAuth(), which provides you with a link to paste # into your browser. The site it leads to then provides you with an # authentication token which you paste into the command line. # Commented out as it is an alternative to the LocalWebserverAuth() above, # and someone will just copy-paste the entire thing into their editor. # gauth.CommandLineAuth() ``` -------------------------------- ### GoogleDriveFile.GetContentString Source: https://docs.iterative.ai/PyDrive2/pydrive2 Retrieves the content of a Google Drive file as a string. ```APIDOC ## GoogleDriveFile.GetContentString ### Description Retrieves the content of a Google Drive file as a string. ### Method GoogleDriveFile.GetContentString() ``` -------------------------------- ### GoogleDriveFile.SetContentString Source: https://docs.iterative.ai/PyDrive2/pydrive2 Sets the content of a Google Drive file from a string. ```APIDOC ## GoogleDriveFile.SetContentString ### Description Sets the content of a Google Drive file from a string. ### Method GoogleDriveFile.SetContentString() ``` -------------------------------- ### pydrive2.apiattr Module Source: https://docs.iterative.ai/PyDrive2/_sources/pydrive2.rst.txt Provides access to the members, undocumented members, and inheritance information for the pydrive2.apiattr module. ```APIDOC ## pydrive2.apiattr Module ### Description This section documents the pydrive2.apiattr module, listing its members, undocumented members, and inheritance. ### Members (Details of members would be listed here if available in the source) ``` -------------------------------- ### IoBuffer.read Source: https://docs.iterative.ai/PyDrive2/pydrive2 Reads data from an IOBuffer. ```APIDOC ## IoBuffer.read ### Description Reads data from an IOBuffer. ### Method IoBuffer.read() ``` -------------------------------- ### GoogleDriveFile.Copy Source: https://docs.iterative.ai/PyDrive2/pydrive2 Creates a copy of the current Google Drive file. This method allows specifying a target folder and a new title for the copied file. Additional parameters can be passed for customization. ```APIDOC ## GoogleDriveFile.Copy ### Description Creates a copy of this file. Folders cannot be copied. ### Method Copy ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **target_folder** (GoogleDriveFile) - Optional - Folder where the file will be copied. - **new_title** (str) - Optional - Name of the new file. - **param** (dict) - Optional - addition parameters to pass. ### Response #### Success Response (200) - **copied_file** (GoogleDriveFile) - The copied file. ### Raises - ApiRequestError ``` -------------------------------- ### GoogleAuth.Authenticate Source: https://docs.iterative.ai/PyDrive2/pydrive2 Authenticates with Google services. ```APIDOC ## GoogleAuth.Authenticate ### Description Authenticates with Google services. ### Method GoogleAuth.Authenticate() ``` -------------------------------- ### Customizable Fields in settings.yaml for PyDrive OAuth Source: https://docs.iterative.ai/PyDrive2/oauth This YAML structure outlines all possible fields for customizing PyDrive's OAuth authentication. Use this to define specific configurations for client credentials, service accounts, and credential saving. ```yaml client_config_backend: {{str}} client_config_file: {{str}} client_config: client_id: {{str}} client_secret: {{str}} auth_uri: {{str}} token_uri: {{str}} redirect_uri: {{str}} revoke_uri: {{str}} service_config: client_user_email: {{str}} client_json_file_path: {{str}} client_json_dict: {{dict}} client_json: {{str}} save_credentials: {{bool}} save_credentials_backend: {{str}} save_credentials_file: {{str}} save_credentials_dict: {{dict}} save_credentials_key: {{str}} get_refresh_token: {{bool}} oauth_scope: {{list of str}} ``` -------------------------------- ### GoogleDriveFile.SetContentFile Source: https://docs.iterative.ai/PyDrive2/pydrive2 Sets the content of a Google Drive file from a file. ```APIDOC ## GoogleDriveFile.SetContentFile ### Description Sets the content of a Google Drive file from a file. ### Method GoogleDriveFile.SetContentFile() ``` -------------------------------- ### ServiceAuth Source: https://docs.iterative.ai/PyDrive2/pydrive2 Authenticates and authorizes the application using a P12 private key, client ID, and client email for a service account. This method is essential for server-to-server interactions. ```APIDOC ## ServiceAuth ### Description Authenticate and authorize using P12 private key, client id and client email for a Service account. ### Raises - **AuthError** - **InvalidConfigError** ``` -------------------------------- ### Create a Folder in Google Drive Source: https://docs.iterative.ai/PyDrive2/_sources/quickstart.rst.txt A function to create a new subfolder within a specified parent folder in Google Drive. It requires the parent folder ID and the desired subfolder name, setting the correct MIME type for folders. ```python def create_folder(parent_folder_id, subfolder_name): newFolder = drive.CreateFile({'title': subfolder_name, "parents": [{"kind": "drive#fileLink", "id": \ parent_folder_id]}],"mimeType": "application/vnd.google-apps.folder"}) newFolder.Upload() return newFolder ``` -------------------------------- ### GoogleDriveFile.UnTrash Source: https://docs.iterative.ai/PyDrive2/pydrive2 Restores a Google Drive file from the trash. ```APIDOC ## GoogleDriveFile.UnTrash ### Description Restores a Google Drive file from the trash. ### Method GoogleDriveFile.UnTrash() ``` -------------------------------- ### Fetch Special File Metadata Source: https://docs.iterative.ai/PyDrive2/filemanagement Fetches specific or all metadata fields for a GoogleDriveFile object using FetchMetadata(). Useful for accessing fields not directly available as dictionary keys. ```python file1 = drive.CreateFile({'id': ''}) # Fetches all basic metadata fields, including file size, last modified etc. file1.FetchMetadata() # Fetches all metadata available. file1.FetchMetadata(fetch_all=True) # Fetches the 'permissions' metadata field. file1.FetchMetadata(fields='permissions') # You can update a list of specific fields like this: file1.FetchMetadata(fields='permissions,labels,mimeType') ``` -------------------------------- ### GoogleDriveFile.GetContentIOBuffer Source: https://docs.iterative.ai/PyDrive2/pydrive2 Provides a file-like object with a buffered read() method for accessing the file's content. This is useful for processing file content in memory without saving it directly to disk. Supports MIME type, encoding, and chunking. ```APIDOC ## GoogleDriveFile.GetContentIOBuffer ### Description Get a file-like object which has a buffered read() method. ### Method GetContentIOBuffer ### Parameters #### Path Parameters None #### Query Parameters - **mimetype** (str) - Optional - mimeType of the file. - **encoding** (str) - Optional - The encoding to use when decoding the byte string. - **remove_bom** (bool) - Optional - Whether to remove the byte order marking. - **chunksize** (int) - Optional - default read()/iter() chunksize. - **acknowledge_abuse** (bool) - Optional - Acknowledging the risk and download file identified as abusive. ### Returns - **MediaIoReadable** - file-like object. ### Raises - ApiRequestError - FileNotUploadedError ``` -------------------------------- ### CheckAuth Source: https://docs.iterative.ai/PyDrive2/pydrive2 Checks the authentication status. ```APIDOC ## CheckAuth ### Description Checks the authentication status. ### Method CheckAuth() ``` -------------------------------- ### GoogleAuth.SaveCredentialsFile Source: https://docs.iterative.ai/PyDrive2/pydrive2 Saves user credentials to a file. ```APIDOC ## GoogleAuth.SaveCredentialsFile ### Description Saves user credentials to a file. ### Method GoogleAuth.SaveCredentialsFile() ``` -------------------------------- ### ValidateSettings Source: https://docs.iterative.ai/PyDrive2/pydrive2 Validates the provided settings data to ensure it is in a correct format. ```APIDOC ## ValidateSettings ### Description Validates if current settings is valid. ### Parameters #### Path Parameters - **data** (dict) - dictionary containing all settings. ### Raises - InvalidConfigError ``` -------------------------------- ### LoadAuth Decorator Source: https://docs.iterative.ai/PyDrive2/pydrive2 A decorator that checks if the current authentication is valid and automatically loads authentication if it is not. This ensures that subsequent operations are performed with valid credentials. ```APIDOC ## LoadAuth Decorator ### Description Decorator to check if the auth is valid and loads auth if not. ### Parameters #### Path Parameters - **decoratee** - The function or method to be decorated. ``` -------------------------------- ### GoogleDriveFile.InsertPermission Source: https://docs.iterative.ai/PyDrive2/pydrive2 Inserts a new permission for a Google Drive file. ```APIDOC ## GoogleDriveFile.InsertPermission ### Description Inserts a new permission for a Google Drive file. ### Method GoogleDriveFile.InsertPermission() ``` -------------------------------- ### Modify and Upload File Content Source: https://docs.iterative.ai/PyDrive2/_sources/filemanagement.rst.txt After downloading file content as a string, you can modify it and then upload the changes back to Google Drive using SetContentString and Upload. This is useful for updating file data. ```python file7.SetContentString(content.replace('lastname', 'familyname')) file7.Upload() # Uploaded content: '{"firstname": "Claudio", "familyname": "Afshar"}' ``` -------------------------------- ### Download File Content with BOM Removal Source: https://docs.iterative.ai/PyDrive2/_sources/filemanagement.rst.txt When downloading text files that might contain Byte Order Marks (BOM), use the remove_bom parameter in GetContentFile or GetContentString to automatically strip the BOM. This prevents parsing issues. ```python # Example usage (assuming 'file_obj' is a GoogleDriveFile instance): # file_obj.GetContentFile('output.txt', remove_bom=True) # file_obj.GetContentString(remove_bom=True) ``` -------------------------------- ### Browse Directory Contents Source: https://docs.iterative.ai/PyDrive2/_sources/quickstart.rst.txt A recursive function to traverse and print the titles of elements within a given folder list. It handles both dictionary (file/folder) and other types of elements. ```python browsed=[] def folder_browser(folder_list,parent_id): for element in folder_list: if type(element) is dict: print (element['title']) else: print (element) print("Enter Name of Folder You Want to Use\nEnter '/' to use current folder\nEnter ':' to create New Folder and ``` -------------------------------- ### SetContentString Source: https://docs.iterative.ai/PyDrive2/pydrive2 Sets the content of a file to a string. It creates a BytesIO instance of the encoded string and sets the mimeType to 'text/plain' if not specified and the file is new. ```APIDOC ## SetContentString ### Description Sets the content of this file to be a string. Creates an io.BytesIO instance of the specified encoded string. Sets mimeType to 'text/plain' if not specified and the file ID is not set (indicating a new upload). ### Method SetContentString ### Parameters #### Query Parameters - **content** (str) - Required - The content of the file in string format. - **encoding** (str) - Optional - The encoding to use when setting the content of this file. Defaults to 'utf-8'. ``` -------------------------------- ### GoogleDriveFile.GetPermissions Source: https://docs.iterative.ai/PyDrive2/pydrive2 Retrieves the permissions associated with a Google Drive file or shared drive. Note that for shared drives, only up to 100 results will be returned without pagination. ```APIDOC ## GoogleDriveFile.GetPermissions ### Description Get file’s or shared drive’s permissions. For files in a shared drive, at most 100 results will be returned. It doesn’t paginate and collect all results. ### Method GetPermissions ### Parameters None ### Returns - **permissions** (object[]) - A list of the permission objects. ### Raises - ApiRequestError ``` -------------------------------- ### Upload File Content from Local File Source: https://docs.iterative.ai/PyDrive2/filemanagement/index.html Uploads the content of a local file to Google Drive. The file is specified by its path. Ensure the file exists before calling this method. ```python file5 = drive.CreateFile() # Read file and set it as a content of this instance. file5.SetContentFile('cat.png') file5.Upload() # Upload the file. print('title: %s, mimeType: %s' % (file5['title'], file5['mimeType'])) # title: cat.png, mimeType: image/png ``` -------------------------------- ### Trash Source: https://docs.iterative.ai/PyDrive2/pydrive2 Moves a file to the trash. This operation can raise an ApiRequestError. ```APIDOC ## Trash ### Description Moves a file to the trash. ### Method Trash ### Parameters #### Query Parameters - **param** (dict) - Optional - Additional parameter for the file operation. ### Raises - ApiRequestError ``` -------------------------------- ### SaveCredentialsFile Source: https://docs.iterative.ai/PyDrive2/pydrive2 Saves authentication credentials to a specified file in JSON format. This is useful for persisting authentication state between sessions. ```APIDOC ## SaveCredentialsFile ### Description Saves credentials to the file in JSON format. ### Parameters #### Path Parameters - **credentials_file** (str) - Optional - destination to save file to. ### Raises - **InvalidConfigError** - **InvalidCredentialsError** ``` -------------------------------- ### Upload File to a Specific Folder Source: https://docs.iterative.ai/PyDrive2/filemanagement Uploads a file into a designated Google Drive folder by specifying the folder's ID in the file's metadata. Requires the folder ID to be known. ```python metadata = { 'parents': [ {"id": id_drive_folder} ], 'title': 'image_test', 'mimeType': 'image/jpeg' } # Create file file = drive.CreateFile(metadata=metadata) file.Upload() ``` -------------------------------- ### Authenticate with PyDrive2 Source: https://docs.iterative.ai/PyDrive2/_sources/quickstart.rst.txt This snippet handles the OAuth2.0 authentication process for Google Drive using PyDrive2's LocalWebserverAuth. It requires a 'client_secrets.json' file in the working directory. ```python from pydrive2.auth import GoogleAuth gauth = GoogleAuth() gauth.LocalWebserverAuth() # Creates local webserver and auto handles authentication. ``` -------------------------------- ### CheckServiceAuth Source: https://docs.iterative.ai/PyDrive2/pydrive2 Checks the service authentication status. ```APIDOC ## CheckServiceAuth ### Description Checks the service authentication status. ### Method CheckServiceAuth() ```