Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to create table in fusion tables returns Invalid credentials
    primarykey
    data
    text
    <p><em><strong>This is the altered code of the sample code given in google to access Fusion tables via python. I want to create table in fusion tables and then insert data... using the post request I managed to write this following code to create a Table by sending a post request. But this is returning an "invalid credentials" error and location being the> Header. Kindly help... or suggest a simple code to create table and insert in Fusion table(data is in txt file). Im very new to this. kindly help.</em></strong></p> <p>Complete CODe:</p> <pre><code>#!/usr/bin/python # Copyright (C) 2011 Google Inc. """ Demostrates use of the new Fusion Tables API """ import urllib2, urllib, simplejson, sys, httplib client_id = "996027904153.apps.googleusercontent.com" client_secret = "secret-given"# redirect_uri = "my localhost" api_key = "my api_key is given" tableid = "1jCqbPu5PjNsczx7cDl3y9EJtSUgNePbvXT7-x70" class RunAPITest: def __init__(self): self.access_token = "" self.params = "" def main(self): print "copy and paste the url below into browser address bar and hit enter" print "https://accounts.google.com/o/oauth2/auth?%s%s%s%s" % \ ("client_id=%s&amp;" % (client_id),"redirect_uri=%s&amp;" % (redirect_uri), "scope=https://www.googleapis.com/auth/fusiontables&amp;","response_type=code") code = raw_input("Enter code (parameter of URL): ") data = urllib.urlencode({ "code": code, "client_id": client_id, "client_secret": client_secret, "redirect_uri": redirect_uri, "grant_type": "authorization_code" }) serv_req = urllib2.Request(url="https://accounts.google.com/o/oauth2/token", data=data) serv_resp = urllib2.urlopen(serv_req) response = serv_resp.read() tokens = simplejson.loads(response) access_token = tokens["access_token"] print access_token self.access_token = access_token print "CREATE TABLE" data='''{ "name": "Insects","columns": [{"name": "Species","type": "STRING"},{"name": "Elevation","type": "NUMBER"},{"name": "Year","type": "DATETIME"}],"description": "Insect Tracking Information.","isExportable": "true"}''' headers={} headers['Authorization']=access_token headers['Content-Type']='application/json' print headers response = self.runRequest("POST","/fusiontables/v1/tables/",data,headers) json_response = simplejson.loads(response) return json_response def runRequest(self, method, url, data=None, headers=None): request = httplib.HTTPSConnection("www.googleapis.com") if data and headers: request.request(method, url, data, headers) else: request.request(method, url) response = request.getresponse() print response.status, response.reason response = response.read() print response return response if __name__ == "__main__": api_test = RunAPITest() api_test.main() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload