We wish to have a program that sign in to gmail account (via IMAP or google API) download all the mails, and saves them in some format that can be read offline (MBOX or Maildir, other format are also possible.)
1) The app should gain access to the user mail via OAUTH2 in a similar way to the following example (i.e using the server-side model, using flask):
[login to view URL] (No need to make things look good).
2) The mails should be saved to the local drive, in a way that some mail reader will be able to read them (Thunderbird, outlook or other. It doesn't matter which one).
The email metadata (such as send date) and attachments should be accessible.
3) The code should be in Python, and should be clear and documented.