читать почту с пользовательской метки в Gmail, используя Python (Google API) - PullRequest
0 голосов
/ 27 июня 2018

Я хочу читать почту с обычного ярлыка ИСПОЛЬЗУЯ PYTHON и Google API. Однако я получаю сообщение об ошибке изменения ярлыка с входящего на обычную ярлык

label_id_one = 'AW'

label_id_two = 'UNREAD'

unread_msgs = GMAIL.users().messages().list(userId='me',labelIds=[label_id_one, label_id_two]).execute()

ПОЛУЧЕНИЕ ЭТОЙ ОШИБКИ:

File "C:\Users\AppData\Local\Programs\Python\Python36-32\lib\site-packages\googleapiclient\discovery.py", line 272, in _retrieve_discovery_doc
    raise HttpError(resp, content, uri=actual_url)
    googleapiclient.errors.HttpError: <HttpError 403 when requesting https://gmail.googleapis.com/$discovery/rest?version=v2 returned "The request cannot be identified with a project. Please pass a valid API key with the request.">

1 Ответ

0 голосов
/ 04 декабря 2018

Я удалил labelID и добавил параметр q, как показано ниже. Здесь «тест» - папка, созданная мной в Gmail.

unread_msgs = GMAIL.users().messages().list(userId='me',q='in:test is:unread').execute()
...