token = xoauth.GenerateXOauthString(consumer, access, MY_EMAIL, 'imap',
    MY_EMAIL, nonce, timestamp)
imap = imaplib.IMAP4_SSL('imap.googlemail.com')
imap.debug = 4
imap.authenticate('XOAUTH', lambda x: token)
msg = email.message.Message()
msg['Subject'] = 'subject of the message'
msg['From'] = MY_EMAIL
msg['To'] = MY_EMAIL
msg.set_payload('Body of the message')
now = imaplib.Time2Internaldate(time.time())
imap.append('[Gmail]/Drafts', '', now, str(msg))
imap.logout()
Programatically Save Draft in Gmail drafts folder