• Hi there. First off, thanks a ton for building this plugin. I spent about 4 hours trying to track down a good bit of code to do the same thing on my blog and low and behold, you had already built and packaged the whole thing for WP. Great! I will absolutely be donating (if possible) once I have it working.
    I am running WP 3.2.1 and have gotten as far as registering my site with Google and entering the oauth key and secret. Now my WP has a red error banner in the admin area:

    Google Latitude History: Your OAuth token is stale, please refresh the token on the settings page. Reason: Login Required

    When I try to refresh the token, I am taken through the two-step Google permission process and am sent back to my WP – but the error remains. If I click “sync latitude history”, I get two messages:

    Error setting Latitude location history

    Google Latitude History was synced

    Any tips would be greatly appreciated.
    Thanks!

    https://www.ads-software.com/extend/plugins/google-latitude-history/

Viewing 15 replies - 1 through 15 (of 20 total)
  • Hi ,

    This is Peter. I am on vacation w/o my laptop so I can’t double check what the code is doing right now. It sounds like you did everything right. The “Iogin required” is a message from the google latitude rest call rejecting your credentials. ll be happy to help when I get back in a week. I am currently using the plugin for my trip to Italy.

    Ciao

    Plugin Author peter2322

    (@peter2322)

    hello,

    i am back from vacation, are you still having this problem? what are the options you are using? you can go to line 313 of google-latitude-history.php file and change:

    echo "Error setting Latitude location history<br/>";

    to

    echo "Error setting Latitude location history: ".$latitudeHistory->error."<br/>";

    what is the error?

    also go to latitudeoauth.php and add thefollowing code at line 193 just below “case ‘GET'”:

    echo $request->to_url()."<br/>";

    what is the url (with the sensitivity keys removed) ?

    Thread Starter jaxonk

    (@jaxonk)

    Hi there Peter,
    Thanks a lot for the reply and help. I tried to send a couple plies before but the internet here is spotty and it looks like they never made it. Either way, hope you had a great time in Italy and welcome home, wherever that is.
    So, I went ahead and changed the first code you mentioned, but I’m not sure where I should be looking for the error output. Also, for the second code change, where should I look for the URL to post for you?
    Thanks again for your time and help!
    Jackson

    Thread Starter jaxonk

    (@jaxonk)

    Poked around a bit more and still am not finding the error that should be echoed or the URL. Tried refreshing the token and syncing again. Neither one seemed to show any errors. Also checked the WP error log, but nothing there. I’m sure the answer is obvious, but I am not finding it. Thanks again for your help.

    Plugin Author peter2322

    (@peter2322)

    You should see the output when you press sync locations from the Google Latitude History settings page.

    The latitudeoauth.php file is located in the latitudeoauth folder. at about line 185 there is a function called “oAuthRequest($url, $method, $parameters)”, in that function there is a switch statement:

    switch ($method) {
    case 'GET':
       return $this->http($request->to_url(), 'GET');
    default:
        return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
    }

    add the line echo $request->to_url()."<br/>"; just below the case ‘GET’: statement.

    Thread Starter jaxonk

    (@jaxonk)

    Thanks a lot for the response Peter. I had the code in the right place, but for whatever reason never managed to get the error message up. Just gave it another shot now and got it up. So here is the error message:
    Catchable fatal error: Object of class stdClass could not be converted to string in /home/mangolan/public_html/wp-content/plugins/google-latitude-history/google-latitude-history.php on line 312
    I can give you access to any part of the site if you need to dig around anymore. Otherwise feel free to shoot any questions or tests my way and I will get back to you right away.
    Thanks,
    Jackson

    Thread Starter jaxonk

    (@jaxonk)

    Pasted the wrong error text before, but edited and corrected it now…

    Plugin Author peter2322

    (@peter2322)

    That is a php error. The function should look like this after the line is pasted in. I think you deleted the return statement.

    function oAuthRequest($url, $method, $parameters) {
        if (strrpos($url, 'https://') !== 0 && strrpos($url, 'https://') !== 0) {
          $url = "{$this->host}{$url}";
        }
        $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
        $request->sign_request($this->sha1_method, $this->consumer, $this->token);
        switch ($method) {
        	case 'GET':
          		echo $request->to_url()."<br/>";
          		return $this->http($request->to_url(), 'GET');
        	default:
          		return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
        }
      }
    Thread Starter jaxonk

    (@jaxonk)

    Okay let’s give this another shot then… I downloaded a fresh copy of the plugin and replaced the file with fresh code. Then added your edit below case ‘GET’. I am still getting the last error I mentioned, but now I’m also getting a more relevant looking error. I’ll post both below, as outputted after hitting “sync…”. I’ve replaced two parts with Xs. Please tell me if those weren’t the right bits to hide…

    https://www.googleapis.com/latitude/v1/location?max-results=90&min-time=1318464000000&oauth_consumer_key=mangolandia.com&oauth_nonce=xxxxxxxxxxxxxxxxxxxxxxxxxx&oauth_signature=xxxxxxxxxxxxxxxxxxxxxxxxxx&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1320532700&oauth_version=1.0
    
    Catchable fatal error: Object of class stdClass could not be converted to string in /home/mangolan/public_html/wp-content/plugins/google-latitude-history/google-latitude-history.php on line 312
    Plugin Author peter2322

    (@peter2322)

    your url looks good. I am not sure where that fatal error is coming from. I have updated the plugin to include displaying the Google Latitude rest service response after you sync the locations. Please download the new 0.9.3 version and after syncing the locations click “see Latitude response” and paste the json data here.

    Thread Starter jaxonk

    (@jaxonk)

    Will do Peter. Should I add the two pieces of code you mentioned previously to this new version as well?
    Also, I was just reading the other support thread and it looks like even getting this resolved won’t actually result in a working map right now. Is that the case?
    Thanks for your time and the update. I’ll try it out tomorrow.

    Plugin Author peter2322

    (@peter2322)

    This update includes allowing the user to see the location data from Google Latitude that is being used to populate the maps (which was the code snippet I was asking you to insert). Several users including myself are receiving empty location data from Google Latitude. I don’t know if this is a widespread issue among Latitude users or widespread among people using my plugin. This update will help you check if it’s the same problem. My suspicion is that since my application was working and didn’t change and Google Latitude is in beta development that something changed on the Google side.

    Thread Starter jaxonk

    (@jaxonk)

    Okay Peter. Got it. I went ahead and installed the new version, re-authorized and tried syncing. Here is the response:

    Error setting Latitude location history
    hide latitude response
    {"error":{"errors":[{"domain":"global","reason":"required","message":"Login Required","locationType":"header","location":"Authorization"}],"code":401,"message":"Login Required"}}

    Plugin Author peter2322

    (@peter2322)

    You are having a different problem then me.

    When you are getting the OAuth token its not being saved. Without this token you will be unable to make requests to the Google Latitude API for your location data. It appears that you have gone through the steps of requesting a token correctly.

    Try this to see if you are getting and saving the token.

    1. In google-latitude-history.php, replace this function:

    function GoogleLatitudeHistory() {
    
            //Inserts Latitude OAuth info into the DB
            if(isset($_REQUEST['oauth_token']) && isset($_REQUEST['oauth_verifier'])) {
    
                    //Create LatitudeOAuth object with app key/secret and token key/secret from default phase
                    $connection = new LatitudeOAuth(get_option('glatitudehistory_oauth_consumer_key'), get_option('glatitudehistory_oauth_consumer_secre\
    t'), $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
    
                    //Request access tokens from google latitude
                    $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
    
                    update_option( 'glatitudehistory_oauth_token', $access_token['oauth_token']);
                    update_option( 'glatitudehistory_oauth_secret', $access_token['oauth_token_secret']);
    
                    header('Location: ' . $_SERVER['SCRIPT_NAME'] . '?page=google-latitude-history-menu');
            }
    
            //Creates Latitude connection
            $this->latitude_con = new LatitudeOAuth(get_option('glatitudehistory_oauth_consumer_key'), get_option('glatitudehistory_oauth_consumer_secre\
    t'), get_option('glatitudehistory_oauth_token'), get_option('glatitudehistory_oauth_secret'));
    }

    with

    function GoogleLatitudeHistory() {
    
            //Inserts Latitude OAuth info into the DB
            if(isset($_REQUEST['oauth_token']) && isset($_REQUEST['oauth_verifier'])) {
    
                    //Create LatitudeOAuth object with app key/secret and token key/secret from default phase
                    $connection = new LatitudeOAuth(get_option('glatitudehistory_oauth_consumer_key'), get_option('glatitudehistory_oauth_consumer_secre\
    t'), $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
    
                    //Request access tokens from google latitude
                    $access_token = $connection->getAccessToken($_REQUEST['oauth_verifier']);
    
                    var_dump($access_token['oauth_token']);
    
                    update_option( 'glatitudehistory_oauth_token', $access_token['oauth_token']);
                    update_option( 'glatitudehistory_oauth_secret', $access_token['oauth_token_secret']);
    
                    header('Location: ' . $_SERVER['SCRIPT_NAME'] . '?page=google-latitude-history-menu');
            }
    
            //Creates Latitude connection
            $this->latitude_con = new LatitudeOAuth(get_option('glatitudehistory_oauth_consumer_key'), get_option('glatitudehistory_oauth_consumer_secre\
    t'), get_option('glatitudehistory_oauth_token'), get_option('glatitudehistory_oauth_secret'));
    }

    2. click “Refresh OAuth Token” on the Google Latitude settings page and go through the 2 screens to grant access. When you are returned to wordpress at the top should be something like:
    string(45) “2/8w-1s2swPQshajsdke9ck333Zb2cQy1nfkEL8”
    If you see this, this is the oauth token. you can change the function back now.

    3. If you see the oauth token there query your wordpress database in query the options table where option_name = ‘glatitudehistory_oauth_token’. You should see the token there too.

    Thread Starter jaxonk

    (@jaxonk)

    Hey there Peter,
    I just tried that twice, but no oauth token appeared. What does that mean?

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘[Plugin: Google Latitude History] Login Required erorr’ is closed to new replies.