GoogleBase authentification with Developper Google Key

5 messages Options
Embed this post
Permalink
Marcel Bariou

GoogleBase authentification with Developper Google Key

Reply Threaded More More options
Print post
Permalink
Hello,

Have somebody idea to authenticate correctly on GoogleBase with
developper Google Key, where to setup this header ? 'X-Google-Key: key =
'.$developer_key

Thanks for some help

Marcel
Ryan Boyd-3

Re: GoogleBase authentification with Developper Google Key

Reply Threaded More More options
Print post
Permalink
On Sun, Apr 27, 2008 at 7:19 AM, Marcel Bariou <[hidden email]> wrote:
Hello,

Have somebody idea to authenticate correctly on GoogleBase with developper Google Key, where to setup this header ? 'X-Google-Key: key = '.$developer_key

Hi Marcel,

I don't believe the X-Google-Key header is strictly required, but here's how you can set it if you wish:

// $client is the Zend_Http_Client object returned from the getHttpClient method in the ClientLogin or AuthSub classes
$client->setHeaders('X-Google-Key', $keyValue);

Hope this helps!

Cheers,
-Ryan



Thanks for some help

Marcel

Marcel Bariou

Re: GoogleBase authentification with Developper Google Key

Reply Threaded More More options
Print post
Permalink
Hello Ryan,
Thanks for your interest. I do the following , I use the Zend Framework,
I make excatly according to / GoogleBase doc, Zend Frame doc, your Mail /
I give you the code below , and the result from the website.....
Have you some ideas about
Thanks for your Help
Marcel


$email='my-gmail [hidden email]';
$password='mypassword';

try{
        $client = Zend_Gdata_ClientLogin::getHttpClient($email,
$password, Zend_Gdata_Gapps::AUTH_SERVICE_NAME);  print
'<BR/><BR/<BR/>VAR_DUMP  CLIENT === ';var_dump($client);
}catch(Exception $e){
        echo "CLASSE => " .$e->getFile()."  MSG => ".$e->getMessage()."
LINE => ".$e->getLine();
        exit();
}
// I try the two following setting with my developper Keys
//$client->setHeaders('X-Google-Key', 'key =
ABQIAAAAHLmpL_pK0jO84FmJbbdwpxRto-o-LgELfUmm3ZH1DZRPxvLnoBR45_Y6juCwlWfBdP87wLpvzLabcw');
$client->setHeaders('X-Google-Key',
'ABQIAAAAHLmpL_pK0jO84FmJbbdwpxRto-o-LgELfUmm3ZH1DZRPxvLnoBR45_Y6juCwlWfBdP87wLpvzLabcw');
$service = new Zend_Gdata_Gbase($client);
$newEntry = $service->newItemEntry();

// Add title
$title = "PHP Developer Handbook";
$newEntry->title = $service->newTitle(trim($title));

// Add some content
$content = "Essential handbook for PHP developers.";
$newEntry->content = $service->newContent($content);
$newEntry->content->type = 'text';

// Define product type
$itemType = "Products";
$newEntry->itemType = $itemType;

// Add item specific attributes
$newEntry->addGbaseAttribute("product_type", "book", "text");
$newEntry->addGbaseAttribute("price", "12.99 USD", "floatUnit");
$newEntry->addGbaseAttribute("quantity", "10", "int");
$newEntry->addGbaseAttribute("weight", "2.2 lbs", "numberUnit");
$newEntry->addGbaseAttribute("condition", "New", "text");
$newEntry->addGbaseAttribute("author", "John Doe", "text");
$newEntry->addGbaseAttribute("edition", "First Edition", "text");
$newEntry->addGbaseAttribute("pages", "253", "number");
$newEntry->addGbaseAttribute("publisher", "My Press", "text");
-- INSERT --      

$dryRun = true;
$createdEntry = $service->insertGbaseItem($newEntry, $dryRun);
=========================================RETURN FROM WEBSITE
==========================
Here I've the answer from the WEBSITE
// I make a dump of the client
// I make a print _r of the return headers, from lines 772, 773, 782
pint_r for $body, $headers and $response


VAR_DUMP CLIENT === object(Zend_Http_Client)#27 (15) {
["config:protected"]=> array(9) { ["maxredirects"]=> int(5)
["strictredirects"]=> bool(true) ["useragent"]=> string(45)
"Zend-ZendFramework Zend_Framework_Gdata/1.5.0" ["timeout"]=> int(10)
["adapter"]=> string(31) "Zend_Http_Client_Adapter_Socket"
["httpversion"]=> string(3) "1.1" ["keepalive"]=> bool(false)
["storeresponse"]=> bool(true) ["strict"]=> bool(true) }
["adapter:protected"]=> NULL ["uri:protected"]=> NULL
["headers:protected"]=> array(1) { ["authorization"]=> array(2) { [0]=>
string(13) "authorization" [1]=> string(241) "GoogleLogin
auth=DQAAAJYAAABQb3HaOWRyVTYnGdN5yQaruznwkyYRGRZtDYfHliW43IVxnZhoXQ-Du4GTCt9Occhztxb-3IjCV4_2kVCExbxP-l76BQa6RNM6UKgjtBcvAYirlZ99tuA-O74Hayz_dsPDaT0kBZBsQR0BbZgbKW3yjAvYTqcviYsodjcrMOfblqlGizaiy4VCxyX1JHoV-I3qbR5EoYv6l5XDD8oQLS05"
} } ["method:protected"]=> string(3) "GET" ["paramsGet:protected"]=>
array(0) { } ["paramsPost:protected"]=> array(0) { }
["enctype:protected"]=> NULL ["raw_post_data:protected"]=> NULL
["auth:protected"]=> NULL ["files:protected"]=> array(0) { }
["cookiejar:protected"]=> NULL ["last_request:protected"]=> NULL
["last_response:protected"]=> NULL ["redirectCounter:protected"]=> int(0) }


BODY ==== PHP Developer HandbookEssential handbook for PHP
developers.Productsbook12.99 USD102.2 lbsNewJohn DoeFirst Edition253My
Press2007Google Checkout


HEADERS ==== Array ( [0] => Host: www.google.com [1] => Connection:
close [2] => Accept-encoding: gzip, deflate [3] => Content-type:
application/atom+xml [4] => User-agent: MyCompany-MyApp-1.0
Zend_Framework_Gdata/1.5.0 [5] => authorization: GoogleLogin
auth=DQAAAJYAAABQb3HaOWRyVTYnGdN5yQaruznwkyYRGRZtDYfHliW43IVxnZhoXQ-Du4GTCt9Occhztxb-3IjCV4_2kVCExbxP-l76BQa6RNM6UKgjtBcvAYirlZ99tuA-O74Hayz_dsPDaT0kBZBsQR0BbZgbKW3yjAvYTqcviYsodjcrMOfblqlGizaiy4VCxyX1JHoV-I3qbR5EoYv6l5XDD8oQLS05
[6] => X-Google-Key:
ABQIAAAAHLmpL_pK0jO84FmJbbdwpxRto-o-LgELfUmm3ZH1DZRPxvLnoBR45_Y6juCwlWfBdP87wLpvzLabcw
[7] => Content-length: 1154 )


RESPONSE ==== HTTP/1.1 401 Token invalid WWW-Authenticate: GoogleLogin
realm="http://www.google.com/accounts/ClientLogin", service="gbase"
Content-Type: text/html; charset=UTF-8 Date: Mon, 28 Apr 2008 09:12:01
GMT Expires: Mon, 28 Apr 2008 09:12:01 GMT Cache-Control: private,
max-age=0 Transfer-Encoding: chunked Server: GFE/1.3 Connection: Close 95


  Token invalid


    Error 401



Ryan Boyd a écrit :

> On Sun, Apr 27, 2008 at 7:19 AM, Marcel Bariou <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hello,
>
>     Have somebody idea to authenticate correctly on GoogleBase with
>     developper Google Key, where to setup this header ? 'X-Google-Key:
>     key = '.$developer_key
>
>
> Hi Marcel,
>
> I don't believe the X-Google-Key header is strictly required, but
> here's how you can set it if you wish:
>
> // $client is the Zend_Http_Client object returned from the
> getHttpClient method in the ClientLogin or AuthSub classes
> $client->setHeaders('X-Google-Key', $keyValue);
>
> Hope this helps!
>
> Cheers,
> -Ryan
>
>
>
>     Thanks for some help
>
>     Marcel
>
>

Ryan Boyd-3

Re: GoogleBase authentification with Developper Google Key

Reply Threaded More More options
Print post
Permalink
Hi Marcel,

The 401 error is likely because you're getting a ClientLogin token for the wrong service.

This line:
 $client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, Zend_Gdata_Gapps::AUTH_SERVICE_NAME)

Should be this for Google Base:
 $client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, Zend_Gdata_Gbase::AUTH_SERVICE_NAME)

Cheers,
-Ryan


On Mon, Apr 28, 2008 at 2:19 AM, Marcel Bariou <[hidden email]> wrote:
Hello Ryan,
Thanks for your interest. I do the following , I use the Zend Framework, I make excatly according to / GoogleBase doc, Zend Frame doc, your Mail /
I give you the code below , and the result from the website.....
Have you some ideas about
Thanks for your Help
Marcel


$email='my-gmail [hidden email]';
$password='mypassword';

try{
      $client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, Zend_Gdata_Gapps::AUTH_SERVICE_NAME);  print '<BR/><BR/<BR/>VAR_DUMP  CLIENT === ';var_dump($client);
}catch(Exception $e){
      echo "CLASSE => " .$e->getFile()."  MSG => ".$e->getMessage()." LINE => ".$e->getLine();
      exit();
}
// I try the two following setting with my developper Keys
//$client->setHeaders('X-Google-Key', 'key = ABQIAAAAHLmpL_pK0jO84FmJbbdwpxRto-o-LgELfUmm3ZH1DZRPxvLnoBR45_Y6juCwlWfBdP87wLpvzLabcw');
$client->setHeaders('X-Google-Key', 'ABQIAAAAHLmpL_pK0jO84FmJbbdwpxRto-o-LgELfUmm3ZH1DZRPxvLnoBR45_Y6juCwlWfBdP87wLpvzLabcw');
$service = new Zend_Gdata_Gbase($client);
$newEntry = $service->newItemEntry();

// Add title
$title = "PHP Developer Handbook";
$newEntry->title = $service->newTitle(trim($title));

// Add some content
$content = "Essential handbook for PHP developers.";
$newEntry->content = $service->newContent($content);
$newEntry->content->type = 'text';

// Define product type
$itemType = "Products";
$newEntry->itemType = $itemType;

// Add item specific attributes
$newEntry->addGbaseAttribute("product_type", "book", "text");
$newEntry->addGbaseAttribute("price", "12.99 USD", "floatUnit");
$newEntry->addGbaseAttribute("quantity", "10", "int");
$newEntry->addGbaseAttribute("weight", "2.2 lbs", "numberUnit");
$newEntry->addGbaseAttribute("condition", "New", "text");
$newEntry->addGbaseAttribute("author", "John Doe", "text");
$newEntry->addGbaseAttribute("edition", "First Edition", "text");
$newEntry->addGbaseAttribute("pages", "253", "number");
$newEntry->addGbaseAttribute("publisher", "My Press", "text");
-- INSERT --      
$dryRun = true;
$createdEntry = $service->insertGbaseItem($newEntry, $dryRun);
=========================================RETURN FROM WEBSITE ==========================
Here I've the answer from the WEBSITE
// I make a dump of the client
// I make a print _r of the return headers, from lines 772, 773, 782 pint_r for $body, $headers and $response


VAR_DUMP CLIENT === object(Zend_Http_Client)#27 (15) { ["config:protected"]=> array(9) { ["maxredirects"]=> int(5) ["strictredirects"]=> bool(true) ["useragent"]=> string(45) "Zend-ZendFramework Zend_Framework_Gdata/1.5.0" ["timeout"]=> int(10) ["adapter"]=> string(31) "Zend_Http_Client_Adapter_Socket" ["httpversion"]=> string(3) "1.1" ["keepalive"]=> bool(false) ["storeresponse"]=> bool(true) ["strict"]=> bool(true) } ["adapter:protected"]=> NULL ["uri:protected"]=> NULL ["headers:protected"]=> array(1) { ["authorization"]=> array(2) { [0]=> string(13) "authorization" [1]=> string(241) "GoogleLogin auth=DQAAAJYAAABQb3HaOWRyVTYnGdN5yQaruznwkyYRGRZtDYfHliW43IVxnZhoXQ-Du4GTCt9Occhztxb-3IjCV4_2kVCExbxP-l76BQa6RNM6UKgjtBcvAYirlZ99tuA-O74Hayz_dsPDaT0kBZBsQR0BbZgbKW3yjAvYTqcviYsodjcrMOfblqlGizaiy4VCxyX1JHoV-I3qbR5EoYv6l5XDD8oQLS05" } } ["method:protected"]=> string(3) "GET" ["paramsGet:protected"]=> array(0) { } ["paramsPost:protected"]=> array(0) { } ["enctype:protected"]=> NULL ["raw_post_data:protected"]=> NULL ["auth:protected"]=> NULL ["files:protected"]=> array(0) { } ["cookiejar:protected"]=> NULL ["last_request:protected"]=> NULL ["last_response:protected"]=> NULL ["redirectCounter:protected"]=> int(0) }


BODY ==== PHP Developer HandbookEssential handbook for PHP developers.Productsbook12.99 USD102.2 lbsNewJohn DoeFirst Edition253My Press2007Google Checkout


HEADERS ==== Array ( [0] => Host: www.google.com [1] => Connection: close [2] => Accept-encoding: gzip, deflate [3] => Content-type: application/atom+xml [4] => User-agent: MyCompany-MyApp-1.0 Zend_Framework_Gdata/1.5.0 [5] => authorization: GoogleLogin auth=DQAAAJYAAABQb3HaOWRyVTYnGdN5yQaruznwkyYRGRZtDYfHliW43IVxnZhoXQ-Du4GTCt9Occhztxb-3IjCV4_2kVCExbxP-l76BQa6RNM6UKgjtBcvAYirlZ99tuA-O74Hayz_dsPDaT0kBZBsQR0BbZgbKW3yjAvYTqcviYsodjcrMOfblqlGizaiy4VCxyX1JHoV-I3qbR5EoYv6l5XDD8oQLS05 [6] => X-Google-Key: ABQIAAAAHLmpL_pK0jO84FmJbbdwpxRto-o-LgELfUmm3ZH1DZRPxvLnoBR45_Y6juCwlWfBdP87wLpvzLabcw [7] => Content-length: 1154 )


RESPONSE ==== HTTP/1.1 401 Token invalid WWW-Authenticate: GoogleLogin realm="http://www.google.com/accounts/ClientLogin", service="gbase" Content-Type: text/html; charset=UTF-8 Date: Mon, 28 Apr 2008 09:12:01 GMT Expires: Mon, 28 Apr 2008 09:12:01 GMT Cache-Control: private, max-age=0 Transfer-Encoding: chunked Server: GFE/1.3 Connection: Close 95


 Token invalid


  Error 401



Ryan Boyd a écrit :

On Sun, Apr 27, 2008 at 7:19 AM, Marcel Bariou <[hidden email] <mailto:[hidden email]>> wrote:

   Hello,

   Have somebody idea to authenticate correctly on GoogleBase with
   developper Google Key, where to setup this header ? 'X-Google-Key:
   key = '.$developer_key


Hi Marcel,

I don't believe the X-Google-Key header is strictly required, but here's how you can set it if you wish:

// $client is the Zend_Http_Client object returned from the getHttpClient method in the ClientLogin or AuthSub classes
$client->setHeaders('X-Google-Key', $keyValue);

Hope this helps!

Cheers,
-Ryan



   Thanks for some help

   Marcel




Marcel Bariou

Re: [Resolve] GoogleBase authentification with Developper Google Key

Reply Threaded More More options
Print post
Permalink
Thanks Ryan for your help.
It runs now, I can proceed ahead. :-)
Have a nice day

Marcel


Ryan Boyd a écrit :

> Hi Marcel,
>
> The 401 error is likely because you're getting a ClientLogin token for
> the wrong service.
>
> This line:
>  $client = Zend_Gdata_ClientLogin::getHttpClient($email, $password,
> Zend_Gdata_Gapps::AUTH_SERVICE_NAME)
>
> Should be this for Google Base:
>  $client = Zend_Gdata_ClientLogin::getHttpClient($email, $password,
> Zend_Gdata_Gbase::AUTH_SERVICE_NAME)
>
> Cheers,
> -Ryan
>
>
> On Mon, Apr 28, 2008 at 2:19 AM, Marcel Bariou <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hello Ryan,
>     Thanks for your interest. I do the following , I use the Zend
>     Framework, I make excatly according to / GoogleBase doc, Zend
>     Frame doc, your Mail /
>     I give you the code below , and the result from the website.....
>     Have you some ideas about
>     Thanks for your Help
>     Marcel
>
>
>     $email='my-gmail [hidden email] <mailto:[hidden email]>';
>     $password='mypassword';
>
>     try{
>           $client = Zend_Gdata_ClientLogin::getHttpClient($email,
>     $password, Zend_Gdata_Gapps::AUTH_SERVICE_NAME);  print
>     '<BR/><BR/<BR/>VAR_DUMP  CLIENT === ';var_dump($client);
>     }catch(Exception $e){
>           echo "CLASSE => " .$e->getFile()."  MSG =>
>     ".$e->getMessage()." LINE => ".$e->getLine();
>           exit();
>     }
>     // I try the two following setting with my developper Keys
>     //$client->setHeaders('X-Google-Key', 'key =
>     ABQIAAAAHLmpL_pK0jO84FmJbbdwpxRto-o-LgELfUmm3ZH1DZRPxvLnoBR45_Y6juCwlWfBdP87wLpvzLabcw');
>     $client->setHeaders('X-Google-Key',
>     'ABQIAAAAHLmpL_pK0jO84FmJbbdwpxRto-o-LgELfUmm3ZH1DZRPxvLnoBR45_Y6juCwlWfBdP87wLpvzLabcw');
>     $service = new Zend_Gdata_Gbase($client);
>     $newEntry = $service->newItemEntry();
>
>     // Add title
>     $title = "PHP Developer Handbook";
>     $newEntry->title = $service->newTitle(trim($title));
>
>     // Add some content
>     $content = "Essential handbook for PHP developers.";
>     $newEntry->content = $service->newContent($content);
>     $newEntry->content->type = 'text';
>
>     // Define product type
>     $itemType = "Products";
>     $newEntry->itemType = $itemType;
>
>     // Add item specific attributes
>     $newEntry->addGbaseAttribute("product_type", "book", "text");
>     $newEntry->addGbaseAttribute("price", "12.99 USD", "floatUnit");
>     $newEntry->addGbaseAttribute("quantity", "10", "int");
>     $newEntry->addGbaseAttribute("weight", "2.2 lbs", "numberUnit");
>     $newEntry->addGbaseAttribute("condition", "New", "text");
>     $newEntry->addGbaseAttribute("author", "John Doe", "text");
>     $newEntry->addGbaseAttribute("edition", "First Edition", "text");
>     $newEntry->addGbaseAttribute("pages", "253", "number");
>     $newEntry->addGbaseAttribute("publisher", "My Press", "text");
>     -- INSERT --      
>     $dryRun = true;
>     $createdEntry = $service->insertGbaseItem($newEntry, $dryRun);
>     =========================================RETURN FROM WEBSITE
>     ==========================
>     Here I've the answer from the WEBSITE
>     // I make a dump of the client
>     // I make a print _r of the return headers, from lines 772, 773,
>     782 pint_r for $body, $headers and $response
>
>
>     VAR_DUMP CLIENT === object(Zend_Http_Client)#27 (15) {
>     ["config:protected"]=> array(9) { ["maxredirects"]=> int(5)
>     ["strictredirects"]=> bool(true) ["useragent"]=> string(45)
>     "Zend-ZendFramework Zend_Framework_Gdata/1.5.0" ["timeout"]=>
>     int(10) ["adapter"]=> string(31) "Zend_Http_Client_Adapter_Socket"
>     ["httpversion"]=> string(3) "1.1" ["keepalive"]=> bool(false)
>     ["storeresponse"]=> bool(true) ["strict"]=> bool(true) }
>     ["adapter:protected"]=> NULL ["uri:protected"]=> NULL
>     ["headers:protected"]=> array(1) { ["authorization"]=> array(2) {
>     [0]=> string(13) "authorization" [1]=> string(241) "GoogleLogin
>     auth=DQAAAJYAAABQb3HaOWRyVTYnGdN5yQaruznwkyYRGRZtDYfHliW43IVxnZhoXQ-Du4GTCt9Occhztxb-3IjCV4_2kVCExbxP-l76BQa6RNM6UKgjtBcvAYirlZ99tuA-O74Hayz_dsPDaT0kBZBsQR0BbZgbKW3yjAvYTqcviYsodjcrMOfblqlGizaiy4VCxyX1JHoV-I3qbR5EoYv6l5XDD8oQLS05"
>     } } ["method:protected"]=> string(3) "GET"
>     ["paramsGet:protected"]=> array(0) { } ["paramsPost:protected"]=>
>     array(0) { } ["enctype:protected"]=> NULL
>     ["raw_post_data:protected"]=> NULL ["auth:protected"]=> NULL
>     ["files:protected"]=> array(0) { } ["cookiejar:protected"]=> NULL
>     ["last_request:protected"]=> NULL ["last_response:protected"]=>
>     NULL ["redirectCounter:protected"]=> int(0) }
>
>
>     BODY ==== PHP Developer HandbookEssential handbook for PHP
>     developers.Productsbook12.99 USD102.2 lbsNewJohn DoeFirst
>     Edition253My Press2007Google Checkout
>
>
>     HEADERS ==== Array ( [0] => Host: www.google.com
>     <http://www.google.com> [1] => Connection: close [2] =>
>     Accept-encoding: gzip, deflate [3] => Content-type:
>     application/atom+xml [4] => User-agent: MyCompany-MyApp-1.0
>     Zend_Framework_Gdata/1.5.0 [5] => authorization: GoogleLogin
>     auth=DQAAAJYAAABQb3HaOWRyVTYnGdN5yQaruznwkyYRGRZtDYfHliW43IVxnZhoXQ-Du4GTCt9Occhztxb-3IjCV4_2kVCExbxP-l76BQa6RNM6UKgjtBcvAYirlZ99tuA-O74Hayz_dsPDaT0kBZBsQR0BbZgbKW3yjAvYTqcviYsodjcrMOfblqlGizaiy4VCxyX1JHoV-I3qbR5EoYv6l5XDD8oQLS05
>     [6] => X-Google-Key:
>     ABQIAAAAHLmpL_pK0jO84FmJbbdwpxRto-o-LgELfUmm3ZH1DZRPxvLnoBR45_Y6juCwlWfBdP87wLpvzLabcw
>     [7] => Content-length: 1154 )
>
>
>     RESPONSE ==== HTTP/1.1 401 Token invalid WWW-Authenticate:
>     GoogleLogin realm="http://www.google.com/accounts/ClientLogin",
>     service="gbase" Content-Type: text/html; charset=UTF-8 Date: Mon,
>     28 Apr 2008 09:12:01 GMT Expires: Mon, 28 Apr 2008 09:12:01 GMT
>     Cache-Control: private, max-age=0 Transfer-Encoding: chunked
>     Server: GFE/1.3 Connection: Close 95
>
>
>      Token invalid
>
>
>       Error 401
>
>
>
>     Ryan Boyd a écrit :
>
>         On Sun, Apr 27, 2008 at 7:19 AM, Marcel Bariou
>         <[hidden email] <mailto:[hidden email]>
>         <mailto:[hidden email] <mailto:[hidden email]>>> wrote:
>
>            Hello,
>
>            Have somebody idea to authenticate correctly on GoogleBase with
>            developper Google Key, where to setup this header ?
>         'X-Google-Key:
>            key = '.$developer_key
>
>
>         Hi Marcel,
>
>         I don't believe the X-Google-Key header is strictly required,
>         but here's how you can set it if you wish:
>
>         // $client is the Zend_Http_Client object returned from the
>         getHttpClient method in the ClientLogin or AuthSub classes
>         $client->setHeaders('X-Google-Key', $keyValue);
>
>         Hope this helps!
>
>         Cheers,
>         -Ryan
>
>
>
>            Thanks for some help
>
>            Marcel
>
>
>
>