blob: fc312ddea214bf769b90f9cefb91813b020cc0f2 [file] [log] [blame]
Joe Gregoriodeeb0202011-02-15 14:49:57 -05001#!/usr/bin/python2.4
2# -*- coding: utf-8 -*-
3#
4# Copyright 2010 Google Inc. All Rights Reserved.
5
6"""Simple command-line example for Latitude.
7
8Command-line application that sets the users
9current location.
10"""
11
12__author__ = 'jcgregorio@google.com (Joe Gregorio)'
13
14import httplib2
15
16from apiclient.discovery import build
17from oauth2client.file import Storage
18from oauth2client.client import OAuth2WebServerFlow
19from oauth2client.tools import run
20
21# Uncomment to get detailed logging
22#httplib2.debuglevel = 4
23
24
25def main():
26 storage = Storage('latitude.dat')
27 credentials = storage.get()
28
29 if not credentials:
30 flow = OAuth2WebServerFlow(
31 client_id='433807057907.apps.googleusercontent.com',
32 client_secret='jigtZpMApkRxncxikFpR+SFg',
33 scope='https://www.googleapis.com/auth/latitude',
34 user_agent='latitude-cmdline-sample/1.0',
35 xoauth_displayname='Latitude Client Example App')
36
37 credentials = run(flow, storage)
38
39 http = httplib2.Http()
40 http = credentials.authorize(http)
41
42 p = build("latitude", "v1", http=http)
43
44 body = {
45 "data": {
46 "kind": "latitude#location",
47 "latitude": 37.420352,
48 "longitude": -122.083389,
49 "accuracy": 130,
50 "altitude": 35
51 }
52 }
53 print p.currentLocation().insert(body=body).execute()
54
55if __name__ == '__main__':
56 main()