anuj607 / google-api-php-client

Automatically exported from code.google.com/p/google-api-php-client
Apache License 2.0
0 stars 0 forks source link

Internal error (500) while trying to access https://www.googleapis.com/userinfo/email #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I have written the following "index.php" in order to get the user email:

session_start();

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

$apiClient = new apiClient();
$user = new apiEasyhybridService($apiClient);

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

$email = $user->getUseremail();
echo "<pre>Email:\n" . print_r($email, true) . "</pre>";

2. I have run the page in a browser.

What is the expected output? What do you see instead?
Expected:
1) Login to google account request
2) Allow the application to access the user email
3) Print the user email

Instead:
1) Login to google account request
2) Allow the application to access the user email
3) Print the following fatal error : 

Fatal error: 
Uncaught exception 'apiServiceException' with message 'Error calling GET 
https://www.googleapis.com/userinfo/email?alt=json: (500) Internal Error' in 
/path/src/io/apiREST.php:85 Stack trace: #0 
/path/src/service/apiServiceResource.php(101): 
apiREST::execute(Object(apiServiceRequest)) #1 
/path/src/contrib/apiEasyhybridService.php(51): 
apiServiceResource->__call('get', Array) #2 /path/examples/index.php(84): 
apiEasyhybridService->getUseremail() #3 {main} thrown in 
/path/src/io/apiREST.php on line 85

What version of the product are you using? On what operating system?

I use the 0.2 version on a LAMP server.

Please provide any additional information below.

I have been able to reproduce this behavior on the google Oauth playground
(http://googlecodesamples.com/oauth_playground/index.php). On the sixtieth 
step, if you try to access to https://www.googleapis.com/userinfo/email with 
"Stick oauth_* params in: Authorization header" everything works fine and it 
returns the user email whereas is you try to access it with "Stick oauth_* 
params in: URL as params" it returns an internal error.

So my opinion was that the parameter "?alt=json" was not properly handled and 
it was the reason why the server was returning this internal error. So I 
managed to remove this parameter from the URL just to figure out if the access 
request was working but I got the same result...

I would be very grateful if you could find a workaround or explain me what I am 
doing wrong .

Thanks for your time.

Original issue reported on code.google.com by marboeu...@gmail.com on 24 Nov 2010 at 9:59

GoogleCodeExporter commented 9 years ago
Here's a small code snippet to help you use the userinfo/email API.

https://groups.google.com/d/msg/google-api-php-client/o1BRsQ9NvUQ/xa532MxegFIJ

Original comment by chirags@google.com on 14 Dec 2011 at 10:18