App Inventor, API Access and Authentication

App Inventor - Gmail Gmail Interface

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. Issue 1889 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!

1. Authenticate via OAuth 2.0

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:
See a list of available scopes here.

Do you need help with your App Inventor project?

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

2. Gmail API Examples

Example: List Messages

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 "". In the example, a list of the message ids will be diplayed in a listpicker to pick a message.

Example: Get Message

Gets the specified message. Pick a message from the listpicker to see the details of the message.

Example: Send Message

Sends the specified message to the recipients in the To, Cc, and Bcc headers.

Further blocks used


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.

Questions and Answers

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.


You can test with the apk file, which is available for download here: Download apk file

Buy the source code for App Inventor

You can buy the source code of this project.
With your payment you accept the terms and conditions below.

Payment options

1. Paypal

Please transfer 10 USD via Paypal.

2. Bitcoin

After having received your payment I will be happy to send the source code to you.
Thank you! Taifun

Please check your spam folder in case you did not receive the example!
I usually will send the project not later than 24 hours after having received your payment.


Terms and Conditions

Back to top of page ...

Home | Snippets | Tutorials | Extensions | News | Forums | Links | Search | Contact