Search code examples
google-maps-api-3google-fusion-tables

Get access to fusion tables


I'd like to show some map layer on my webpage, so I decided to give a try to this Google service. As the data is collected in a database in my server, I chose to use a service account as explained here and then use the private key generated in my php script.

Everything works fine when creating a table and inserting some test values. I get the table Id and I'm able to play with it from my script. The problem is that I don't know how to access these table from the web browser. In my API console usage stats are shown fine, but when logging with my account to Google Drive I don't see any table in there.

Where am I supposed to access them if at all possible? Do either the apps.googleusercontent.com or developer.gserviceaccount.com accounts play any role to log into some other service to get access through web?

I also got an api key associated, but when trying to query a table I get a 401 error.

Any hint? I'm feeling a bit lost now. Thanks.


Solution

  • You are using a Service Account right? So when you create a table with this account, this account will be the table owner. No one else has permission to see this table.

    When you access the Fusion Tables web interface with Your Personal Account, you will only see tables that you createdwith your Personal Account.

    If you wish to inspect the tables created with your Service Account, you have to use the Google Drive API with your Service Account credentials to give access permission to your Personal Account. Also if you wish to make your table (or any other type of document) public, you need to use this Google Drive API again. See more about the topic here:

    https://developers.google.com/drive/v2/reference/permissions/insert

    Tip: if you want to achieve something on behalf of your Service Account that you only need once (so no need to implement a logic for it in your webapp) I'd seriously advise you to consider using the OAuth2 Playground. You can set your Service Account credentials in the "Settings" and issue authorized requests on behalf of your Service Account. Very usefull tool, no coding needed.