def get_authenticators(self): if self.request.method == "GET": return [ Auth(), ] else: return [ CoerceAuth(), ]
def __init__(self): sys.path.append(os.path.join(os.path.dirname(__file__), '..')) parser = argparse.ArgumentParser(prog='nester') parser.add_argument('-v', '--version', action='version', version='%(prog)s 0.1') parser.add_argument('-l', '--log', type=str, required=False, help='The output log file') subparsers = parser.add_subparsers(dest='command', help='sub commands') auth = Auth(os.environ['NEST_CONTACT_EMAIL']) if auth.load(): auth.get_token() auth.save() objects = [ App(auth), #Forest(auth), #Tree(auth), Content(auth), Nest(auth), #Domain(auth), #Certificate(auth), #Contact(auth), #DevKit(auth), Deployment(auth), Data(auth) ] for the_obj in objects: the_obj.parse_command(subparsers) args = parser.parse_args() print('\n') for the_obj in objects: if the_obj.exec_command(args) == True: break
import io import os from googleapiclient.errors import HttpError from googleapiclient.http import MediaIoBaseDownload, MediaFileUpload from httplib2 import Http from oauth2client import file from apiclient.discovery import build from DatShiroShop.models import Song from api.auth import Auth SCOPES = 'https://www.googleapis.com/auth/drive' store = file.Storage('credentials.json') auth = Auth(SCOPES, store) creds = auth.getCredentials() shiro_store_folder_id = '1E1_y5_-vW6Qwvh0aXkQ3DK5cYq2ZaVY2' shiro_store_user_folder_id = '11PJLtUpw2U1u7Sm-acxYYaoi_QbIWhg5' service = build('drive', 'v3', http=creds.authorize(Http())) downloads_path = os.path.expanduser(os.sep.join(["~", "Downloads"])) def list_files(size=10, folder_id=shiro_store_folder_id): results = service.files().list( pageSize=10, fields="nextPageToken, files(id, name)", q="'{0}' in parents".format(folder_id)).execute() items = results.get('files', []) if not items: print('No files found.')