0
votes

I have a fusion table that I wish to do inserts and updates to that I have created through Google Docs.

I am trying to use OAUTH to access this table and do inserts and updates both through a WebApp and Java Client

I can do a select to this table with my access token (that I receive through passing my client secret and refresh token credentials) no problem programatically.

String sql = java.net.URLEncoder.encode("SELECT * FROM " + tableId, "ISO-8859-1");
uri = "https://www.google.com/fusiontables/api/query?access_token=" + token + "&sql=" + sql;

The above returns me my rows from the table

However, when I try to do an insert I GET THE MESSAGE below

Server returned HTTP response code: 403 for URL: https://www.google.com/fusiontables/api/query?access_token.....

The insert will only work if I first create tables from within the Google API programatically. How can I make sure that I can access the same tables. I create though New Tables Option Under "Google Docs" I see where there is a share button, but I don't know the steps to open a table up for inserts, updates that I can execute an insert without getting a 403 response from the Google server programmatically. Am I not the owner? How do I register my API credentials with the table for insert/update?

1

1 Answers

1
votes

Still fairly new to Fusion tables myself, but I've recently built a javascript web app that does insert/updates to a table.

Firstly, if it's a javascript web-app, you need to authorise the URL from which the update/inserts will be coming from. Do that via the Google API Console...

https://code.google.com/apis/console/

...under the "API access" menu item -- "JavaScript origins" is the bit you need to add your servers hostnames to. Any insert/updates to the table need to be made via an SSL connection (ie. the page in question needs to start with HTTPS://

You shouldn't need to worry about this if you're using POST data from server-side code -- the important thing in that instance is (I think) to ensure that that data is still being transmitted via SSL (although, not 100% sure on that, as I'm working exclusively in the world of client-side javascript).

Also make sure the Fusion Table API is toggled to ON (under the "Services" menu).

I found these two pages...

http://code.google.com/p/google-api-javascript-client/wiki/Authentication https://developers.google.com/fusiontables/docs/v1/using#auth

...incredibly useful for getting my head around the authentication process, and this sample page...

http://gmaps-samples.googlecode.com/svn/trunk/fusiontables/javascript-api.html

...actually provided the specific code that ended my flailing, and allowed me to make some progress on pushing data into my fusion table.