• Hi hope you can help I have recently upgraded to 3.3.1 for use on a website I am running for my brother on his cycling expedition. http://ridetheamericas.co.uk

    I have just updated the google API details obtaining a new key and secret, but have just noticed the callback URI on google API page doesnt match the URI path on the wordpress admin page.

    When I try to refresh the token ohe plugin setings page I am getting Error:redirect_uri_mismatch from google page

    To be honest I have yet to get the plugin working correctly on the previous versions. Althugh my brother has been travelling since 31 Oct 2011 the plugin will only display 2 locations. This is despite having the correct date criteria and number of marker etc.

    Would be grateful if you could help.

    Leigh

    http://wordpress.org/extend/plugins/google-latitude-history/

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author peter2322

    (@peter2322)

    Hi Leigh,

    Thanks for trying the plugin and letting me know about a problem. I hope we can get this working for you because your website is a great use for this plugin.

    Just to double check, you updated the Google API console with the redirect uri listed in the Google Latitude History plugin settings page as shown in screenshot-6?

    What is the Redirect URI listed in Google Latitude plugin and the url listed on the Google error page?

    Thread Starter ridetheadmericasadmin

    (@ridetheadmericasadmin)

    Sorry I really should have read the updated instructions properly.

    However I have checked the URI is now correct in google API.

    When I try to refresh the token I am getting the following error

    Fatal error: Uncaught exception ‘apiAuthException’ with message ‘Error fetching OAuth2 access token, message: ‘invalid_client” in /www/sites/59b/675/www.ridetheamericas.co.uk/web/wp-content/plugins/google-latitude-history/google-api-php-client/src/auth/apiOAuth2.php:108 Stack trace: #0 /www/sites/59b/675/www.ridetheamericas.co.uk/web/wp-content/plugins/google-latitude-history/google-api-php-client/src/apiClient.php(132): apiOAuth2->authenticate(Array) #1 /www/sites/59b/675/www.ridetheamericas.co.uk/web/wp-content/plugins/google-latitude-history/google-latitude-history.php(126): apiClient->authenticate() #2 /www/sites/59b/675/www.ridetheamericas.co.uk/web/wp-content/plugins/google-latitude-history/google-latitude-history.php(50): GoogleLatitudeHistory->GoogleLatitudeHistory() #3 /www/sites/59b/675/www.ridetheamericas.co.uk/web/wp-settings.php(196): include_once(‘/www/sites/59b/…’) #4 /www/sites/59b/675/www.ridetheamericas.co.uk/web/wp-config.php(83): require_once(‘/www/sites/59b/…’) #5 /www/sites/59b/675/www.ridetheam in /www/sites/59b/675/www.ridetheamericas.co.uk/web/wp-content/plugins/google-latitude-history/google-api-php-client/src/auth/apiOAuth2.php on line 108

    Can anyone advise?

    Plugin Author peter2322

    (@peter2322)

    No problem, wordpress doesnt really give a good way to notify the user when updating the plugin about changes :(.

    I was able to recreate that error when the client secret on the plugin settings page didnt match the one in the Google API console. Please double check your client secret and let me know if that’s the problem

    Thanks for pointing that out to me, in the next version I will handle that error better.

    Thread Starter ridetheadmericasadmin

    (@ridetheadmericasadmin)

    Ok this time I have refreshed the client secret and entered this in the wordpress settings screen.

    THis time I am getting the following error, when I try to refresh the token.

    Your OAuth token is stale, please refresh the token on the settings page. Reason: Could not create storage directory: /tmp/apiClient/8b

    Any ideas!

    Plugin Author peter2322

    (@peter2322)

    This must be a permissions issue. If you navigate to /tmp/apiClient/ and create the “8b” directory ( mkdir 8b ). Does this solve the problem?

    I will try and find a better solution for this problem.

    Thread Starter ridetheadmericasadmin

    (@ridetheadmericasadmin)

    I will try later when I can get access to the host.

    THanks

    Thread Starter ridetheadmericasadmin

    (@ridetheadmericasadmin)

    I’ve had a look and the directory /tmp/apiClient doesnt exist anywhere. Either at the root of the directory structure or within the plugin directory.

    I have tried creating the directories in both locations with full permissions (777) and am still getting the same error.

    Plugin Author peter2322

    (@peter2322)

    To recap, I am using third party code, Google-API-PHP-Client, to handle the OAuth 2 tokens. The code caches the access key and token in a file. The problem you having is some kind of permissions issue. Do you have access to the server logs? Can your web hoster provide any assistance? The directory that should be created at the root (cd /tmp/apiClient/8b).

    In the meantime, I can try and implement the caching using the wordpress database instead of a file which should get around your problem.

    Plugin Author peter2322

    (@peter2322)

    Hello,

    I have written a work around to the file system problem. I have implemented the caching in the wordpress database. I am not ready to release the next update of this plugin but I will provide the steps to implement it.

    1. create the following table in the wordpress database. Replace $PREFIX with your wordpress database table prefix located in the wp-config.php file under $table_prefix like wp_api_cache.

    CREATE TABLE $PREFIXapi_cache
    (
    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    k VARCHAR(32),
    data TEXT,
    expiration TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
    );

    2. Create the following file under wp-content/plugins/google-latitude-history/google-api-php-client/src/cache/apiWordpressDatabaseCache.php

    <?php
    /*
     * Copyright 2011 World Travel Blog
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    /*
     * This class implements the cache with a WordPress Database.
     * Below if the WordPress table this class uses. Replace $PREFIX
     * with your WordPress database prefix ($wpdb->prefix) when
     * creating the table.
     *
     * CREATE TABLE $PREFIX . _api_cache
     * (
     * 		id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
     * 		k VARCHAR(32),
     * 		data TEXT,
     * 		expiration TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
     * );
     *
     * @author Peter Rosanelli <peter@worldtravelblog.com>
     */
    
    class apiWordpressDatabaseCache extends apiCache {
    	private $apiCacheTable; 
    
     	public function __construct() {
        	global $apiConfig;
        	global $wpdb;
    
        	$this->apiCacheTable = $wpdb->prefix . 'api_cache';;
      	}
    
    	/**
    	 * Retrieves the data for the given key, or false if they
    	 * key is unknown or expired
         *
         * @param String $key The key who's data to retrieve
         * @param boolean|int $expiration Expiration time in seconds
         *
        */
    	public function get($key, $expiration = false) {
    		global $wpdb;
    
    		$result = $wpdb->get_row("SELECT * FROM " . $this->apiCacheTable . " WHERE K = '" . $key . "'");
    
    		if($result) {
    			$now = time();
    
          		if (! $expiration || (($mtime = strtotime($result->expiration)) !== false && ($now - $mtime) < $expiration)) {
          			$data = unserialize($result->data);
              		return $data;
    			}
    		}
    
    		return false;
      	}
    
    	/**
       	 * Store the key => $value set. The $value is serialized
    	 * by this function so can be of any type
    	 *
    	 * @param String $key Key of the data
    	 * @param $value the data
    	*/
      	public function set($key, $value) {
      		global $wpdb;
    
      		$data = serialize($value);
    
      		$result = $wpdb->get_row("SELECT * FROM " . $this->apiCacheTable . " WHERE K = '" . $key . "'");
    
      		if($result) {
    
      			 $wpdb->update( $this->apiCacheTable, array(
      			 	'data' => $data
      			 ), array(
      			 	'k' => $key
      			 ), array(
      			 	'%s'
      			 ), array(
      			 	'%s'
      			 )); 
    
      		} else {
    
      			$wpdb->insert( $this->apiCacheTable, array(
    				'k' => $key,
    				'data' => $data
    			), array( '%s', '%s' ) );
      		}
    	}
    
    	/**
    	 * Removes the key/data pair for the given $key
    	 *
    	 * @param String $key
    	*/
    	public function delete($key) {
      		global $wpdb;
    
    		$wpdb->query("DELETE FROM " . $this->apiCacheTable . " WHERE k = '" . $key . "'" );
    
    	}
    
    }

    3. In wp-content/plugins/google-latitude-history/google-api-php-client/src/config.php at ~ line 47:

    'cacheClass'   => 'apiFileCache',

    to

    'cacheClass'   => 'apiWordpressDatabaseCache',

    4, Refresh your Oauth token and you should be done!

    i got the same problem! tried everything, but it just doenst seem to work…that is so frustrating!

    Plugin Author peter2322

    (@peter2322)

    @makcim, I helped ridetheadmericasadmin through several issues, which problem do you have?

    – if your problem is creating the ” /tmp/apiClient” files/folders, have you tried the 4 step solutions above? If you are having this same problem I can release this code sooner.

    hey pete! thx for a prompt answer!
    in the beginning i had the same problem as ridetheadmericasadmin. i guess i have fixed it?! however, now i have that /tmp/apiClient” files/folders problem. i did try the 4 steps above, but it doesn`t seem to work. i gotta say, i am not quite good with css, but i will give it another try!

    If you are having this same problem I can release this code sooner.
    i think that would be quite helpful! thank you and will feedback soon!

    Plugin Author peter2322

    (@peter2322)

    @makcim,

    no problem, thanks for trying my plugin.

    since you and ridetheadmericasadmin are having this problem then 20 other people are probably having it too, so i will update the plugin with the fix above. Give me 2-3 days.

    Plugin Author peter2322

    (@peter2322)

    hi,

    I have update the plugin with the code fix, please give it a shot and let me know if it works. thanks.

    awesome! thank you! it does work! But i think there is some bug in it, which affects the visuals…check that… http://www.maximdewald.com/sample-page/?preview=true&preview_id=2&preview_nonce=fcaf0f78b4

    however, thank you for your assistance! i am happy with it!

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘[Plugin: Google Latitude History] Problem with new release – Callback URI greyed out’ is closed to new replies.