Created
April 10, 2017 10:17
-
-
Save eduardoaugustojulio/444b3fb366df3e6924609ed54105a29d to your computer and use it in GitHub Desktop.
Makes a google api connection using oauth2 and query select from fusiontables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import simplejson as json | |
import webbrowser | |
import httplib2 | |
from apiclient import discovery | |
from oauth2client import client | |
from apiclient.discovery import build | |
from apiclient.discovery import build | |
if __name__ == '__main__': | |
flow = client.flow_from_clientsecrets( | |
'client_secrets.json', | |
scope='https://www.googleapis.com/auth/fusiontables', | |
redirect_uri='urn:ietf:wg:oauth:2.0:oob') | |
auth_uri = flow.step1_get_authorize_url() | |
webbrowser.open(auth_uri) | |
auth_code = raw_input('Enter the auth code: ') | |
credentials = flow.step2_exchange(auth_code) | |
http_auth = credentials.authorize(httplib2.Http()) | |
fusion_service = discovery.build('fusiontables', 'v2' , http_auth) | |
json_result = fusion_service.query().sql(sql="SELECT * FROM 19P8oeOLsHiGEfdXv5dm_OU_CJ4A8xPOAvJRKEe9I").execute() | |
string_result = json.dumps(json_result) | |
dic_result = json.loads(string_result) | |
print dic_result['rows'].translate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment