How to use the Service account option to connect to a Fusiontable
Thank you Steven for being the sponsor of this tutorial!
Precondition: you already have done the Pizza Party tutorial and you already created a fusiontable, which means, you already have a table id.
There is one major disadvantage using the fusiontables as described in the Pizza Party tutorial, which is:
To share a FusionTable with others, you have to share it with each person individually, or you can share with a Google Group,
the same way you would share a private google doc. There is no way to share write privileges to a FusionTable with the public. Public access is restricted to read-only.
To avoid this disadvantage, just use the service account option. There are the following steps for the setup:
- Developers Console: create a Service Account. After creating a service account in the developer console you get a p12 file to download
and a service account email to use in App Inventor.
- FusionTable: share the FusionTable with the ServiceAccount Email address and set the permissions to "can edit".
- App Inventor: The p12 file must be uploaded as asset into App Inventor and this is the file referenced to in the Keyfile property,
see also screenshot of the App Inventor Blocks editor below.
Detailed steps including screenshots
Note: These detailed steps have been updated on Nov. 22nd, 2015. Unfortunately Google changes the user interface frequently, which means,
the steps to do are still the same, only the user interface looks a little bit different now.
- Open the Google Developers Console and create a new project,
just click "Create Proejct".
- Enter a project name (do not use spaces in the project name to avoid spaces in the file name later),
use the suggested project id and click "Create".
The project will be created.
- Then in the Project Dashboard click onto "Enable and manage APIs"
- Disable all APIs and enable the Fusiontables API
- In the Credentials tab click onto "Add credentials"
- Then select "Service Account", click P12 and then "Create"
- A keyfile will be generated, just store it in a directory of your computer
Then click "Close"
- You can find the service account email address in the "Credentials" window
- To be able to copy the email, click onto the email and another window will open. Copy the email address from there to the clipboard
- Now go to the Consent tab, select your email address, add a product name and click "Save"
- Go to your Google drive, open your Fusiontable and click "File" - "Share"
- In the following window share the FusionTable with the ServiceAccount Email address (see Developers Console step 8), set the permissions to "can edit"
and disable the checkbox "Notify people by email".
- Now, the Sharing settings will look like this
3. App Inventor
You can use the App Inventor test project from the Download section below to test the connection to your fusiontable.
- Download the example project from here and upload it into App Inventor.
- In the App Inventor Designer upload the keyfile (from step 7) into App Inventor
- In the Blocks Editor adjust the TABLE_ID, KeyFile and ServiceAccountEmail
- Connect the companion app and click button "Select" in the example app to get a list of all rows of your fusiontable.
In case you get problems, see also Frequent Made Errors with Fusiontables and how to fix them.
Download serviceaccount aia file
Download serviceaccount apk file to test the example using my test table
Back to top of page ...
This work by Pura Vida Apps
is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
with attribution (name=Pura Vida Apps and link to the source site) required.