music2storage/service.py
def connect(self):
        """Creates connection to the Google Drive API, sets the connection attribute to make requests, and creates the Music folder if it doesn't exist."""

        SCOPES = 'https://www.googleapis.com/auth/drive'
        store = file.Storage('drive_credentials.json')
        creds = store.get()
        if not creds or creds.invalid:
            try:
                flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
            except InvalidClientSecretsError:
                log.error('ERROR: Could not find client_secret.json in current directory, please obtain it from the API console.')
                return
            creds = tools.run_flow(flow, store)
        self.connection = build('drive', 'v3', http=creds.authorize(Http()))

        response = self.connection.files().list(q="name='Music' and mimeType='application/vnd.google-apps.folder' and trashed=false").execute()
        try:
            folder_id = response.get('files', [])[0]['id']
        except IndexError:
            log.warning('Music folder is missing. Creating it.')
            folder_metadata = {'name': 'Music', 'mimeType': 'application/vnd.google-apps.folder'}
            folder = self.connection.files().create(body=folder_metadata, fields='id').execute()
def connect(self):
        """Creates connection to the Google Drive API, sets the connection attribute to make requests, and creates the Music folder if it doesn't exist."""

        SCOPES = 'https://www.googleapis.com/auth/drive'
        store = file.Storage('drive_credentials.json')
        creds = store.get()
        if not creds or creds.invalid:
            try:
                flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
            except InvalidClientSecretsError:
                log.error('ERROR: Could not find client_secret.json in current directory, please obtain it from the API console.')
                return
            creds = tools.run_flow(flow, store)
        self.connection = build('drive', 'v3', http=creds.authorize(Http()))

        response = self.connection.files().list(q="name='Music' and mimeType='application/vnd.google-apps.folder' and trashed=false").execute()
        try:
            folder_id = response.get('files', [])[0]['id']
        except IndexError:
            log.warning('Music folder is missing. Creating it.')
            folder_metadata = {'name': 'Music', 'mimeType': 'application/vnd.google-apps.folder'}
            folder = self.connection.files().create(body=folder_metadata, fields='id').execute()
Creates connection to the Google Drive API, sets the connection attribute to make requests, and creates the Music folder if it doesn't exist.