I've read all the documentation available online and scoured the web,
but I'm still having issues importing gmail contacts using secure
AuthSub on a registered page with a digital signature.

I've been able to import contacts just fine using the non-secure
method with the following code:

if (isset($_GET["token"]))
{
        $_SESSION["c_token"] = Zend_Gdata_AuthSub::getAuthSubSessionToken(trim
($_GET["token"]));
        session_write_close();
        header("Location: http://www.XXXXXXX.com/gmailinvite.php";);
}

if (!isset($_SESSION["c_token"]))
{
        $scope = "http://www.google.com/m8/feeds";;
        $uri = Zend_Gdata_AuthSub::getAuthSubTokenUri("http://
www.XXXXXXXX.com/gmailinvite.php", $scope, 0, 1);
        header("Location: ".$uri);
        exit(1);
}

However, when I try to do so securely, using a digital signature, I
receive a fatal error from Zend 'Zend_Gdata_App_AuthException, Token
upgrade failed, Invalid AuthSub header, Error 401.  Here's the code:

if (isset($_GET["token"]))
{
        $client = new Zend_Gdata_HttpClient();
        $client->setAuthSubPrivateKeyFile("googkey.pem",null,true);
        $_SESSION["c_token"] = Zend_Gdata_AuthSub::getAuthSubSessionToken(trim
($_GET["token"]), $client);
        session_write_close();
        header("Location: http://www.XXXXXXXXXX.com/gmailinvite.php";);
}

if (!isset($_SESSION["c_token"]))
{
        $scope = "http://www.google.com/m8/feeds";;
        $uri = Zend_Gdata_AuthSub::getAuthSubTokenUri("http://
www.XXXXXXXXX.com/gmailinvite.php", $scope, 1, 1);
        header("Location: ".$uri);
        exit(1);
}

The private key (googkey.pem) is in the same directory as the running
php file, and has read access.  It seems that the
setAuthSubPrivateKeyFile function is reading the file just fine, as
when I change the filename to some jibberish, I receive numerous other
stream errors since it can't read the file.

Has anyone successfully completed this secure contact import with
PHP?  Can you please provide some guidance?

Thanks so much,

Michael
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Contacts API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-contacts-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to