/**
 * Created by Neil on 29/09/13.
 */
function signin(mode, callback, clientID) { // clientID filled in by template, immediate = true because we should not need to ask permission again
    gapi.auth.authorize({client_id: clientID,
            scope: ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"], immediate: true,
            response_type: 'token'}, // Can't use id tokens as we can't get the user if from an id token
        callback);
}

function userAuthed() {

    var request =
        gapi.client.oauth2.userinfo.get().execute(function (resp) { // Check the token by calling userinfo, if it's ok call our end point
            if (!resp.code) {
                var token = gapi.auth.getToken();
                gapi.client.mylatitude.locations.latest().execute(function (resp) { // this does not do anything yet it's just a test.
//                    console.log(resp);
                });
            }
        });
}

@@ -37,219 +37,513 @@
  */%0A
-function signin(mode, callback, clientID) %7B // clientID filled in by template, immediate = true because we sh
+/**%0A * @fileoverview%0A * Provides methods to access the google client endpoints including the myLatitude API and handle the logging%0A * in etc.%0A *%0A * @author Neil Parley%0A */%0A/** myLatitude namespace for Javascript */%0Avar myLatitude = myLatitude %7C%7C %7B%7D;%0A/** myLatitude.endpoints namespace for cl
 ou
-l
 d 
-not need to ask permission again%0A    gapi.auth.authorize(%7Bclient_id: clientID,%0A       
+endpoints functions */%0AmyLatitude.endpoints = %7B%7D;%0A(function() %7B%0A/**%0A *   Keep hold of the client id etc so we can get at them again later.%0A */%0A    var client_id = null;%0A    var api_root = null;%0A
     
+var
  scope
-:
+s =
  %5B%22h
@@ -589,16 +589,36 @@
 .email%22,
+%0A                   
  %22https:
@@ -665,66 +665,830 @@
 le%22%5D
-, immediate: true,%0A            response_type: 'token'%7D, //
+;%0A    this.refreshToken = true;%0A/**%0A *   Loads the mylatitude API and the google oauth2 API%0A *   once both have loaded call myLatitude.endpoints.signin%0A */%0A    this.loadBackEnd = function (clientID, apiRoot, apiStartFunction) %7B%0A        client_id = clientID;%0A        api_root = apiRoot;%0A        var apisToLoad;%0A        var callback = function () %7B%0A            if (--apisToLoad == 0) %7B%0A                myLatitude.endpoints.signin(true, apiStartFunction);%0A            %7D%0A        %7D;%0A        apisToLoad = 2;%0A        gapi.client.load('mylatitude', 'v1', callback, api_root);%0A        gapi.client.load('oauth2', 'v2', callback);%0A    %7D;%0A/**%0A *   Authorize the user against the API and set the access tokens%0A *   clientID filled in by template, immediate = true because we should not need to ask permission again for the backend%0A *  
  Can
@@ -1530,17 +1530,17 @@
 e user i
-f
+d
  from an
@@ -1552,211 +1552,392 @@
 oken
-%0A        callback);%0A%7D%0A%0Afunction userAuthed() %7B%0A%0A    var request =%0A        gapi.client.oauth2.userinfo.get().execute(function (resp) %7B // Check the token by calling userinfo, if it's ok call our end point
+, so need bearer token%0A */%0A    this.signin = function (mode, callback) %7B%0A        gapi.auth.authorize(%7Bclient_id: client_id, scope: scopes, immediate: mode%7D, callback);%0A    %7D;%0A%0A/**%0A *   Default function to be called after authorize just gets the user information from the token%0A */%0A    this.userAuthed = function() %7B%0A%0A        gapi.client.oauth2.userinfo.get().execute(function (resp) %7B
 %0A   
@@ -2100,59 +2100,8 @@
 p) %7B
- // this does not do anything yet it's just a test.
 %0A// 
@@ -2184,10 +2184,46 @@
     %7D);%0A
-%7D
+    %7D%0A%7D).apply(myLatitude.endpoints);
 %0A

Rewrite of endpoint.js into myLatitude.endpoints name space. Provides functions for connecting the Google Client Library.