Wiki

Clone wiki

myLatitude / Setup App

Create a Google App Engine App

Go to https://console.developers.google.com/project and create a project. The name of the app will be used in the URL. For example myapp will have the url myapp.appspot.com. Once you have created the app you can view the dashboard etc for your app, by visiting the link above.

Create Google API access for the App

The code uses Google Maps and Google's sign in to authenticate users. To set this up go to https://console.developers.google.com/project/myapp which is the dashboard for your project. Then go to APIs and Auth section and select API. In the API search box type these APIs and enable them:

  • Google Maps API v3
  • Google Maps Geolocation API
  • Google+ API

Screen Shot 2015-07-21 at 20.39.36.png

Then click on Consent Screen on the left under the API sub menu. This needs to be set up before we can create our client IDs. Fill in the product name field with our app name and the url with the url of your app like the example below.

Screen Shot 2015-07-21 at 20.45.55.png

Once you click save you will be asked to create a new client ID. Select Web Applications. Fill in the fields with the following:

Screen Shot 2015-07-21 at 20.53.26.png

Then click on create create client ID. Once you have set that up click Download JSON, you will need this client.secret file later.

Click create new key under the Public API access. In the Create New Key menu select Browser Key. In the next menu, in the accept requests from these server IP address box add: https://yourapp.appspot.com/* and http://localhost. Then click create.

Screen Shot 2015-07-21 at 21.00.39.png

The string of letters next to API key will be needed later.

Screen Shot 2015-07-21 at 21.02.01 copy.png

Download the Google App Engine SDK

You need this to upload the app to the google app engine servers. You need to download the python version for your OS from here: https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Python

Get a copy of the myLatitude App Code

Download the latest zip, or clone the git repo into a directory. In this directory copy your client_secret file you downloaded earlier (you might need to rename the file to client_secrets.json from the name it is downloaded as something.json). Also you need to edit the app.yaml file. Inside the app.yaml file change the application name to the name of your app that you pick when signing up to Google App Engine.

For Mac OsX and Windows: load the Google app engine launcher. Click on create new application and then fill in the application name and the parent directory. Making sure that Python 2.7 is selected as the runtime.

Screen Shot 2015-07-21 at 21.10.26.png

Once created you can test the app by clicking on the run button. Once it is running you can visit http://localhost:8080/ and once you sign in with you Google id and give the app permission it should tell you that you don't have permission to access the page. Which is correct as we have not done the setup. But we might as well do that on the remote server so stop the app and click deploy. This will upload the code to the Google app engine servers.

For Linux: to test the code will run use: google_appengine/dev_appserver.py app_folder_path/ and then to upload the code type: google_appengine/appcfg.py --oauth2 update app_folder_path/

Set up the myLatitude app

Visit https://yourapp.appspot.com/setup and here you need to type in your name (normally already filled in) and your maps api. This is the new browser key you created earlier. Copy and past it into the box and sudmit the form. You could be told your app is set-up and it will give you a key. This is your random key which you use in backitude as your password to upload your location to the app.

If you now go to https://yourapp.appspot.com/ you should see a Google map centred on Edinburgh castle. (As you have no location points yet).

Set up Backitude

The backitude custom server settings to work with this app are:

  • Server URL: https://yourapp.appspot.com/backitude
  • Response Codes: 200,201
  • Auth Options: None
  • User Name: <leave blank>
  • Password: <leave blank>
  • Custom Field 1: your random key created during setup

The field names are (click to see image):

  • User Name: username (not used)
  • Password: password (not used)
  • Latitude: latitude
  • Longitude: longitude
  • Accuracy: accuracy
  • Speed: speed
  • Altitude: altitude
  • Direction Bearing: (No Value)
  • Location Timestamp: utc_timestamp
  • Requestion Timestamp: req_timestamp
  • Timezone Offset: (No Value)
  • Custom Field 1: key

Once you have set-up these values you can click on run test to test the connect to your app engine server. Also in advanced settings make sure that time zone offset is not selected. The app assumes all timestamps are UTC so the data is not affected if the time zone information on the phone is incorrect.

Timestamps

This app uses UTC timestamps for all the uploads and does not require the timezone. When the time since update is displayed to the web page it is converted from UTC to the users local timezone. Also the history page automatically works out the correct time zone from the location data.

Backitude has two timestamps utc_timestamp and req_timestamp. utc_timestamp is the timestamp when the location data was collected, i.e. the time when the GPS sensor was polled for example. req_timestamp is the time at which backitude sent the request to the Android location API. These affect things if you are using location roll-back because the utc_timestamp will not change on posts where a rollback has happened. Therefore even though backitude has sent another update to the server your users will not see this.

I prefer location roll-back being off so each location poll produces a new utc_timestamp along with new location data, and even if I have not moved it will still show that I am updating my location. If you like location roll-back you might prefer using req_timestamp to show you are still updating when your location is staying the same. This needs a code change in latMain.py, change:

            timestamp = int(self.request.POST['utc_timestamp']) -> timestamp = int(self.request.POST['req_timestamp'])

You will need to re-upload your app to Google App Engine once you have made this change in the code.

Once you have setup backitude you should be able to fire an update and then going to: https://yourapp.appspot.com/ should show you your location on a map.

Updated