Note: Google was modernizing OAuth interactions in Native Apps for Better Usability and Security,
which means, this solution to receive an access token via webview unfortunately does not work anymore starting from April 20, 2017.
Use the Mail extension instead...
This example uses the new Gmail REST API.
In this example the user can get a list of his last 10 Gmail messages, pick a message to see the details and send a message.
is no issue anymore.
Update: I fixed a small issue concerning base64 encoding of the message to send. The message must be web-safe base64 encoded, for details see also here.
Authorization of the user is required on first start of the app (similar to the App Inventor - Fusiontable interface and the App Inventor - Google Drive interface). Alternatively if you store your refresh token inside the app, you can use the example without need to login to send or receive emails from a Gmail account, which could be created especially for your app!
For your own app, first register your application as described here,
to be able to use OAuth to access Google APIs. In "APIs", just enable the Gmail API instead.
Then use these blocks for the further basic steps of the OAuth process.
In the authorization process, I'm currently using the following scope: https://mail.google.com/.
See a list of available scopes here.
I can help you: for one hour I charge 25 USD.
Please contact me at info [at] puravidaapps [dot] com for details!
For questions about App Inventor, please use the App Inventor forum. Thank you.
To use the example without login, then follow these steps
Lists the messages in the user's mailbox.
I restricted the list with the maxResults parameter to get only the last 10 messages.
You also could use the q parameter to return messages matching the specified query, for example "from:email@example.com". In the example, a list of the message ids will be diplayed in a listpicker to pick a message.
Gets the specified message. Pick a message from the listpicker to see the details of the message.
The Gmail API offers loads of possibilities. However I think, we can't send messages with attachments from within App Inventor using the Gmail API, because App Inventor does not offer multipart upload. For sending emails with attachments or sending HTML formatted emails, see my Mail extension.
Tested successfully on Nexus 5 running Android 4.4.4.
Q1:I can get the list of my emails and read them, but I can't send anything. The error message is: "page not found". Have you had any idea of what could it be? Or how can I fix it?
A: As I mentioned here I did not convert = into a websafe format. You can try to modify the webSafeBase64 procedure in Screen2 and additionally convert = to *.
Feedback from user: I had to put a space after the email to send correctly. Other thing I modified the webSafeBase64 procedure as you said and then the app works pretty well.