Search code examples
javascriptgoogle-oauthgoogle-maps-engine

How can I permit external edits of a Map Engine DataTable?


The flow of data here is somewhat circuitous, but I'm not aware of any other way to accomplish what I want to do. My ultimate desire is to have a web page displaying a route I've mapped out in Google Map Engine with my current location being shown and updated periodically. I am currently updating a Google Spreadsheet with location data via the IFTTT Android app. I've already figured out how to get that data via JavaScript on my Google Sites website (the spreadsheet's permissions are set to allow anyone with the URL to access it). Additionally, I have figured out the correct API call to make via the API Explorer to update the DataTable (batchPatch). However, I have not figured out how to allow the script to update these values in my DataTable when it is activated by other people visiting the site (these people will only be the people I permit, via Google's permissions system, to access the site, but could possibly be expanded to anyone I share the link with).

Ultimately, it seems that Google's permissions system was intended only for people accessing and modifying their own data in some way. Is there any way to allow other people (or rather the JavaScript on the site) to access and modify my data?


Solution

  • Maps Engine doesn't have a "public write" permission, but you can set up a service account (non-human / non-gmail style account) and grant it permission to write.

    The docs describing service account authentication in Maps Engine are here: https://developers.google.com/maps-engine/documentation/oauth/serviceaccount

    Typically this is implemented by setting up the actions you wish to be public (e.g. map edit) on a server and have the clients call your server, rather than making the requests directly from the client code.