Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when granularity="best" in Latitude service #5

Closed
GoogleCodeExporter opened this issue Mar 28, 2016 · 9 comments
Closed

Error when granularity="best" in Latitude service #5

GoogleCodeExporter opened this issue Mar 28, 2016 · 9 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Create a script with this content :

<?php

    require_once "../../src/apiClient.php";
    require_once "../../src/contrib/apiLatitudeService.php";

    require_once "includes/header.php";

    $apiClient = new apiClient();
    $lat = new apiLatitudeService($apiClient);

    if (isset($_SESSION['auth_token'])) {
      $apiClient->setAccessToken($_SESSION['auth_token']);
    } else {
      $_SESSION['auth_token'] = $apiClient->authenticate();
    }

    $latitude1 = $lat->getCurrentLocation('city');

    echo "<pre>";
    print_r($latitude1);
    echo "</pre>";

    $latitude2 = $lat->getCurrentLocation('best');

    echo "<pre>";
    print_r($latitude2);
    echo "</pre>";

?>

2. Execute the script and look the result


What is the expected output? What do you see instead?
The result to the line "$latitude1 = $lat->getCurrentLocation('city');" works, 
the position is returned, but
the line "$latitude2 = $lat->getCurrentLocation('best');" return an error :
Fatal error: Uncaught exception 'apiServiceException' with message 'Error 
calling 
https://www.googleapis.com/latitude/v1/currentLocation?granularity=best&alt=json
: (401) Invalid Credentials' in 
/home/www/9d39bf010a3c15d51e47350ba58958ce/web/src/io/apiREST.php:85 Stack 
trace: #0 
/home/www/9d39bf010a3c15d51e47350ba58958ce/web/src/service/apiServiceResource.ph
p(101): apiREST::execute(Object(apiServiceRequest)) #1 
/home/www/9d39bf010a3c15d51e47350ba58958ce/web/src/contrib/apiLatitudeService.ph
p(115): apiServiceResource->__call('get', Array) #2 
/home/www/9d39bf010a3c15d51e47350ba58958ce/web/examples/latitude/getLatitude.php
(30): apiLatitudeService->getCurrentLocation('best') #3 {main} thrown in 
/home/www/9d39bf010a3c15d51e47350ba58958ce/web/src/io/apiREST.php on line 85

What version of the product are you using? On what operating system?
Library version: google-api-php-client 0.2
OS: Linux


Please provide any additional information below.


Original issue reported on code.google.com by david.an...@gmail.com on 21 Jan 2011 at 5:51

@GoogleCodeExporter
Copy link
Author

Hello,

I've just tested your script on my localhost with WAMP. My result is that I've 
been redirected to this page :
https://www.google.com/latitude/b/0/apps?latitudeAuthResponse=INVALID_REQUEST_PA
RAMS

Do I have to specify an ApiKey or something ?

Original comment by jgarnie...@gmail.com on 28 Apr 2011 at 10:40

@GoogleCodeExporter
Copy link
Author

My knowledge of this is pretty minimal (I've learned just enough to do what I 
need to do...) but my understanding is you need to authorise the request with 
an OAuth access token. Your code structure differs from mine, but maybe you'll 
get the idea?

if(!$accessToken=unserialize(file_get_contents('/home/lee/latitude/token.txt')))
 die('Unable to read access token.');
$client = $accessToken->getHttpClient($oauthOptions);

My token is stored in a text file, that is then read each time the script runs 
to pull location data.

Original comment by lee.smal...@gmail.com on 28 Apr 2011 at 5:36

@GoogleCodeExporter
Copy link
Author

I am having the same problem :

https://www.google.com/latitude/b/0/apps?latitudeAuthResponse=INVALID_REQUEST_PA
RAMS

Original comment by 50Pix....@gmail.com on 17 Jun 2011 at 1:52

@GoogleCodeExporter
Copy link
Author

Is your token authorised to use 'best' ? There are 2 request types, city and 
best. Your token needs to have the right authority.

Original comment by lee.smal...@gmail.com on 17 Jun 2011 at 4:29

@GoogleCodeExporter
Copy link
Author

Now after I'm authorized and redirected back to my site I get the following : 



Fatal error: Uncaught exception 'apiCacheException' with message 'Cache file 
could not be deleted' in 
/var/www/sites/web2era/public_html/googleapi/src/cache/apiFileCache.php:132 
Stack trace: #0 
/var/www/sites/web2era/public_html/googleapi/src/auth/apiOAuth.php(76): 
apiFileCache->delete('OAuth:anonymous...') #1 
/var/www/sites/web2era/public_html/googleapi/src/apiClient.php(130): 
apiOAuth->authenticate(Object(apiFileCache), Object(apiCurlIO), Array) #2 
/var/www/sites/web2era/public_html/googleapi/examples/index.php(37): 
apiClient->authenticate() #3 {main} thrown in 
/var/www/sites/web2era/public_html/googleapi/src/cache/apiFileCache.php on line 
132 



you can test it at : 

http://web2era.com/googleapi/examples/



Original comment by lickstr....@gmail.com on 17 Jun 2011 at 7:15

@GoogleCodeExporter
Copy link
Author

I am having the same problem  401  Invalid Credentials . . (This is a new 
problem) It was working before there's something Wrong @ google's Side . . 

Original comment by shehabic on 18 Jun 2011 at 1:28

@GoogleCodeExporter
Copy link
Author

I think comment #4 above is correct.  I have seen a similar error because the 
token was authorized with an improper scope.  

In src/config.php i changed the scope for latitude to .all.best and that fixed 
the error.  Other scopes are likely appropriate for different uses.


Original comment by krkee...@gmail.com on 17 Aug 2011 at 11:17

@GoogleCodeExporter
Copy link
Author

It looks like the latitude API deprecated the 
https://www.googleapis.com/auth/latitude scope and replaced it with the 
following scopes:
   https://www.googleapis.com/auth/latitude.all.best
   https://www.googleapis.com/auth/latitude.all.city

I've included these scopes in the latest version of the client library, see 
http://code.google.com/p/google-api-php-client/source/browse/trunk/src/config.ph
p#63

If you want to use granularity="best", you'll need to use the scope 
'https://www.googleapis.com/auth/latitude.all.best'

Original comment by chirags@google.com on 31 Aug 2011 at 4:56

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Issue 8 has been merged into this issue.

Original comment by chirags@google.com on 31 Aug 2011 at 4:57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant