Google API Python Client: working with Google Fusion Tables

Finally I’ve managed to work google-api-python-client. It has really strange interface.

So, the working code:

import httplib2
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials

# Here's the file you get from API Console -> Service Account.
f = file('key.p12', 'rb')
key = f.read()
f.close()

# Create an httplib2.Http object to handle our HTTP requests and authorize it
  # with the Credentials. Note that the first parameter, service_account_name,
  # is the Email address created for the Service account. It must be the email
  # address associated with the key that was created.
credentials = SignedJwtAssertionCredentials(
    '...@developer.gserviceaccount.com',
    key,
    scope='https://www.googleapis.com/auth/fusiontables')
http = httplib2.Http()
http = credentials.authorize(http)

service = build("fusiontables", "v1", http=http)
# For example, let make SQL query to SELECT ALL from Table with
# id = 1gvB3SedL89vG5r1128nUN5ICyyw7Wio5g1w1mbk
print(service.query().sql(sql='SELECT * FROM 1gvB3SedL89vG5r1128nUN5ICyyw7Wio5g1w1mbk').execute())