I'm building a website using flask, in which people can authorize my website for their gmail account using the Flask-OAuthlib. The initial authorization works fine and after that I can get the userinfo like this:
userinfo = google.get('userinfo')
print userinfo.raw_data # prints out a raw json object with the userinfo
I then tried getting a list of messages. I can do it using a raw url like this:
import requests
emailList = requests.get('https://www.googleapis.com/gmail/v1/users/' + userId + '/messages?access_token=' + accessToken)
print emailList.json() # prints out a list of message `id`s and `threadId`s
But I don't understand how I can do this using the Flask OAuthlib. I tried some of the following things, but none of them works:
messages = google.get('messages')
messages = google.get('/users/' + userId + '/messages')
messages = google.get('users')
messages = google.get('usermessages') # I know this sucks, but I'm pretty desperate..
Does anybody know how I can get the list of messages (and after that the individual messages) with this Flask OAuthlib? All tips are welcome!
bonus question: Is there a way to search messages by string and by whether they have an attachment or not?